You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by javaxmlsoapdev <vi...@yahoo.com> on 2009/11/13 17:09:22 UTC

how to search against multiple attributes in the index

I want to build AND search query against field1 AND field2 etc. Both these
fields are stored in an index. I am migrating lucene code to Solr. Following
is my existing lucene code

BooleanQuery currentSearchingQuery = new BooleanQuery();

currentSearchingQuery.add(titleDescQuery,Occur.MUST);
highlighter = new Highlighter( new QueryScorer(titleDescQuery));
				
TermQuery searchTechGroupQyery = new TermQuery(new Term
("techGroup",searchForm.getTechGroup()));
	currentSearchingQuery.add(searchTechGroupQyery, Occur.MUST);
TermQuery searchProgramQyery = new TermQuery(new
Term("techProgram",searchForm.getTechProgram()));
	currentSearchingQuery.add(searchProgramQyery, Occur.MUST);
}

What's the equivalent Solr code for above Luce code. Any samples would be
appreciated.

Thanks,
-- 
View this message in context: http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339025.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: how to search against multiple attributes in the index

Posted by javaxmlsoapdev <vi...@yahoo.com>.
great. thanks. that was helpful

Avlesh Singh wrote:
> 
>>
>> you can do it using
>> solrQuery.setFilterQueries() and build AND queries of multiple
>> parameters.
>>
> Nope. You would need to read more -
> http://wiki.apache.org/solr/FilterQueryGuidance
> 
> For your impatience, here's a quick starter -
> 
> #and between two fields
> solrQuery.setQuery("+field1:foo +field2:bar");
> 
> #or between two fields
> solrQuery.setQuery("field1:foo field2:bar");
> 
> Cheers
> Avlesh
> 
> On Fri, Nov 13, 2009 at 10:35 PM, javaxmlsoapdev <vi...@yahoo.com>
> wrote:
> 
>>
>> I think I found the answer. needed to read more API documentation :-)
>>
>> you can do it using
>> solrQuery.setFilterQueries() and build AND queries of multiple
>> parameters.
>>
>>
>> Avlesh Singh wrote:
>> >
>> > For a starting point, this might be a good read -
>> >
>> http://www.lucidimagination.com/search/document/f4d91628ced293bf/lucene_query_to_solr_query
>> >
>> > Cheers
>> > Avlesh
>> >
>> > On Fri, Nov 13, 2009 at 10:02 PM, javaxmlsoapdev <vi...@yahoo.com>
>> > wrote:
>> >
>> >>
>> >> I already did  dive in before. I am using solrj API and SolrQuery
>> object
>> >> to
>> >> build query. but its not clear/written how to build booleanQuery
>> ANDing
>> >> bunch of different attributes in the index. Any samples please?
>> >>
>> >> Avlesh Singh wrote:
>> >> >
>> >> > Dive in - http://wiki.apache.org/solr/Solrj
>> >> >
>> >> > Cheers
>> >> > Avlesh
>> >> >
>> >> > On Fri, Nov 13, 2009 at 9:39 PM, javaxmlsoapdev <vi...@yahoo.com>
>> >> wrote:
>> >> >
>> >> >>
>> >> >> I want to build AND search query against field1 AND field2 etc.
>> Both
>> >> >> these
>> >> >> fields are stored in an index. I am migrating lucene code to Solr.
>> >> >> Following
>> >> >> is my existing lucene code
>> >> >>
>> >> >> BooleanQuery currentSearchingQuery = new BooleanQuery();
>> >> >>
>> >> >> currentSearchingQuery.add(titleDescQuery,Occur.MUST);
>> >> >> highlighter = new Highlighter( new QueryScorer(titleDescQuery));
>> >> >>
>> >> >> TermQuery searchTechGroupQyery = new TermQuery(new Term
>> >> >> ("techGroup",searchForm.getTechGroup()));
>> >> >>        currentSearchingQuery.add(searchTechGroupQyery, Occur.MUST);
>> >> >> TermQuery searchProgramQyery = new TermQuery(new
>> >> >> Term("techProgram",searchForm.getTechProgram()));
>> >> >>        currentSearchingQuery.add(searchProgramQyery, Occur.MUST);
>> >> >> }
>> >> >>
>> >> >> What's the equivalent Solr code for above Luce code. Any samples
>> would
>> >> be
>> >> >> appreciated.
>> >> >>
>> >> >> Thanks,
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339025.html
>> >> >> Sent from the Solr - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339402.html
>> >> Sent from the Solr - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339903.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26340776.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: how to search against multiple attributes in the index

Posted by Avlesh Singh <av...@gmail.com>.
>
> you can do it using
> solrQuery.setFilterQueries() and build AND queries of multiple parameters.
>
Nope. You would need to read more -
http://wiki.apache.org/solr/FilterQueryGuidance

For your impatience, here's a quick starter -

#and between two fields
solrQuery.setQuery("+field1:foo +field2:bar");

#or between two fields
solrQuery.setQuery("field1:foo field2:bar");

Cheers
Avlesh

On Fri, Nov 13, 2009 at 10:35 PM, javaxmlsoapdev <vi...@yahoo.com> wrote:

>
> I think I found the answer. needed to read more API documentation :-)
>
> you can do it using
> solrQuery.setFilterQueries() and build AND queries of multiple parameters.
>
>
> Avlesh Singh wrote:
> >
> > For a starting point, this might be a good read -
> >
> http://www.lucidimagination.com/search/document/f4d91628ced293bf/lucene_query_to_solr_query
> >
> > Cheers
> > Avlesh
> >
> > On Fri, Nov 13, 2009 at 10:02 PM, javaxmlsoapdev <vi...@yahoo.com>
> > wrote:
> >
> >>
> >> I already did  dive in before. I am using solrj API and SolrQuery object
> >> to
> >> build query. but its not clear/written how to build booleanQuery ANDing
> >> bunch of different attributes in the index. Any samples please?
> >>
> >> Avlesh Singh wrote:
> >> >
> >> > Dive in - http://wiki.apache.org/solr/Solrj
> >> >
> >> > Cheers
> >> > Avlesh
> >> >
> >> > On Fri, Nov 13, 2009 at 9:39 PM, javaxmlsoapdev <vi...@yahoo.com>
> >> wrote:
> >> >
> >> >>
> >> >> I want to build AND search query against field1 AND field2 etc. Both
> >> >> these
> >> >> fields are stored in an index. I am migrating lucene code to Solr.
> >> >> Following
> >> >> is my existing lucene code
> >> >>
> >> >> BooleanQuery currentSearchingQuery = new BooleanQuery();
> >> >>
> >> >> currentSearchingQuery.add(titleDescQuery,Occur.MUST);
> >> >> highlighter = new Highlighter( new QueryScorer(titleDescQuery));
> >> >>
> >> >> TermQuery searchTechGroupQyery = new TermQuery(new Term
> >> >> ("techGroup",searchForm.getTechGroup()));
> >> >>        currentSearchingQuery.add(searchTechGroupQyery, Occur.MUST);
> >> >> TermQuery searchProgramQyery = new TermQuery(new
> >> >> Term("techProgram",searchForm.getTechProgram()));
> >> >>        currentSearchingQuery.add(searchProgramQyery, Occur.MUST);
> >> >> }
> >> >>
> >> >> What's the equivalent Solr code for above Luce code. Any samples
> would
> >> be
> >> >> appreciated.
> >> >>
> >> >> Thanks,
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339025.html
> >> >> Sent from the Solr - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339402.html
> >> Sent from the Solr - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339903.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>

Re: how to search against multiple attributes in the index

Posted by javaxmlsoapdev <vi...@yahoo.com>.
I think I found the answer. needed to read more API documentation :-)

you can do it using 
solrQuery.setFilterQueries() and build AND queries of multiple parameters.


Avlesh Singh wrote:
> 
> For a starting point, this might be a good read -
> http://www.lucidimagination.com/search/document/f4d91628ced293bf/lucene_query_to_solr_query
> 
> Cheers
> Avlesh
> 
> On Fri, Nov 13, 2009 at 10:02 PM, javaxmlsoapdev <vi...@yahoo.com>
> wrote:
> 
>>
>> I already did  dive in before. I am using solrj API and SolrQuery object
>> to
>> build query. but its not clear/written how to build booleanQuery ANDing
>> bunch of different attributes in the index. Any samples please?
>>
>> Avlesh Singh wrote:
>> >
>> > Dive in - http://wiki.apache.org/solr/Solrj
>> >
>> > Cheers
>> > Avlesh
>> >
>> > On Fri, Nov 13, 2009 at 9:39 PM, javaxmlsoapdev <vi...@yahoo.com>
>> wrote:
>> >
>> >>
>> >> I want to build AND search query against field1 AND field2 etc. Both
>> >> these
>> >> fields are stored in an index. I am migrating lucene code to Solr.
>> >> Following
>> >> is my existing lucene code
>> >>
>> >> BooleanQuery currentSearchingQuery = new BooleanQuery();
>> >>
>> >> currentSearchingQuery.add(titleDescQuery,Occur.MUST);
>> >> highlighter = new Highlighter( new QueryScorer(titleDescQuery));
>> >>
>> >> TermQuery searchTechGroupQyery = new TermQuery(new Term
>> >> ("techGroup",searchForm.getTechGroup()));
>> >>        currentSearchingQuery.add(searchTechGroupQyery, Occur.MUST);
>> >> TermQuery searchProgramQyery = new TermQuery(new
>> >> Term("techProgram",searchForm.getTechProgram()));
>> >>        currentSearchingQuery.add(searchProgramQyery, Occur.MUST);
>> >> }
>> >>
>> >> What's the equivalent Solr code for above Luce code. Any samples would
>> be
>> >> appreciated.
>> >>
>> >> Thanks,
>> >> --
>> >> View this message in context:
>> >>
>> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339025.html
>> >> Sent from the Solr - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339402.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339903.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: how to search against multiple attributes in the index

Posted by Avlesh Singh <av...@gmail.com>.
For a starting point, this might be a good read -
http://www.lucidimagination.com/search/document/f4d91628ced293bf/lucene_query_to_solr_query

Cheers
Avlesh

On Fri, Nov 13, 2009 at 10:02 PM, javaxmlsoapdev <vi...@yahoo.com> wrote:

>
> I already did  dive in before. I am using solrj API and SolrQuery object to
> build query. but its not clear/written how to build booleanQuery ANDing
> bunch of different attributes in the index. Any samples please?
>
> Avlesh Singh wrote:
> >
> > Dive in - http://wiki.apache.org/solr/Solrj
> >
> > Cheers
> > Avlesh
> >
> > On Fri, Nov 13, 2009 at 9:39 PM, javaxmlsoapdev <vi...@yahoo.com>
> wrote:
> >
> >>
> >> I want to build AND search query against field1 AND field2 etc. Both
> >> these
> >> fields are stored in an index. I am migrating lucene code to Solr.
> >> Following
> >> is my existing lucene code
> >>
> >> BooleanQuery currentSearchingQuery = new BooleanQuery();
> >>
> >> currentSearchingQuery.add(titleDescQuery,Occur.MUST);
> >> highlighter = new Highlighter( new QueryScorer(titleDescQuery));
> >>
> >> TermQuery searchTechGroupQyery = new TermQuery(new Term
> >> ("techGroup",searchForm.getTechGroup()));
> >>        currentSearchingQuery.add(searchTechGroupQyery, Occur.MUST);
> >> TermQuery searchProgramQyery = new TermQuery(new
> >> Term("techProgram",searchForm.getTechProgram()));
> >>        currentSearchingQuery.add(searchProgramQyery, Occur.MUST);
> >> }
> >>
> >> What's the equivalent Solr code for above Luce code. Any samples would
> be
> >> appreciated.
> >>
> >> Thanks,
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339025.html
> >> Sent from the Solr - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339402.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>

Re: how to search against multiple attributes in the index

Posted by javaxmlsoapdev <vi...@yahoo.com>.
I already did  dive in before. I am using solrj API and SolrQuery object to
build query. but its not clear/written how to build booleanQuery ANDing
bunch of different attributes in the index. Any samples please?

Avlesh Singh wrote:
> 
> Dive in - http://wiki.apache.org/solr/Solrj
> 
> Cheers
> Avlesh
> 
> On Fri, Nov 13, 2009 at 9:39 PM, javaxmlsoapdev <vi...@yahoo.com> wrote:
> 
>>
>> I want to build AND search query against field1 AND field2 etc. Both
>> these
>> fields are stored in an index. I am migrating lucene code to Solr.
>> Following
>> is my existing lucene code
>>
>> BooleanQuery currentSearchingQuery = new BooleanQuery();
>>
>> currentSearchingQuery.add(titleDescQuery,Occur.MUST);
>> highlighter = new Highlighter( new QueryScorer(titleDescQuery));
>>
>> TermQuery searchTechGroupQyery = new TermQuery(new Term
>> ("techGroup",searchForm.getTechGroup()));
>>        currentSearchingQuery.add(searchTechGroupQyery, Occur.MUST);
>> TermQuery searchProgramQyery = new TermQuery(new
>> Term("techProgram",searchForm.getTechProgram()));
>>        currentSearchingQuery.add(searchProgramQyery, Occur.MUST);
>> }
>>
>> What's the equivalent Solr code for above Luce code. Any samples would be
>> appreciated.
>>
>> Thanks,
>> --
>> View this message in context:
>> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339025.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339402.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: how to search against multiple attributes in the index

Posted by Avlesh Singh <av...@gmail.com>.
Dive in - http://wiki.apache.org/solr/Solrj

Cheers
Avlesh

On Fri, Nov 13, 2009 at 9:39 PM, javaxmlsoapdev <vi...@yahoo.com> wrote:

>
> I want to build AND search query against field1 AND field2 etc. Both these
> fields are stored in an index. I am migrating lucene code to Solr.
> Following
> is my existing lucene code
>
> BooleanQuery currentSearchingQuery = new BooleanQuery();
>
> currentSearchingQuery.add(titleDescQuery,Occur.MUST);
> highlighter = new Highlighter( new QueryScorer(titleDescQuery));
>
> TermQuery searchTechGroupQyery = new TermQuery(new Term
> ("techGroup",searchForm.getTechGroup()));
>        currentSearchingQuery.add(searchTechGroupQyery, Occur.MUST);
> TermQuery searchProgramQyery = new TermQuery(new
> Term("techProgram",searchForm.getTechProgram()));
>        currentSearchingQuery.add(searchProgramQyery, Occur.MUST);
> }
>
> What's the equivalent Solr code for above Luce code. Any samples would be
> appreciated.
>
> Thanks,
> --
> View this message in context:
> http://old.nabble.com/how-to-search-against-multiple-attributes-in-the-index-tp26339025p26339025.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>