Passing Multiple value to solr Query

4,155 views
Skip to first unread message

Siva

unread,
Jul 18, 2011, 10:53:29 AM7/18/11
to SolrNet
Hi,
Can some help regarding querying solr fields.
I have indexed my db fields and all stored in filed called
"search_text"

In my Database I got "Air Line Industry" and it is related keywords
are
"Air Hostess" or "Aeroplane" or "Airline" or "Airplane" or
"Aircraft" or "Airport" or or "Pilots" or "Travel Cushion" or
"Travel Wallet".

In my Site i got dropdown list with "Air Line Industry". If some one
select this item, i need to get the related keywords from db (above
keywords) and make call to solr to search these keywords.

I am bit struck.. if any one help how we can pass multiple values to
solr to search.

Thanks
Siva

Mauricio Scheffer

unread,
Jul 18, 2011, 1:31:38 PM7/18/11
to sol...@googlegroups.com
SolrQueryInList is probably what you're looking for: http://code.google.com/p/solrnet/wiki/Querying#Query_by_list_of_values

--
Mauricio



--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To post to this group, send email to sol...@googlegroups.com.
To unsubscribe from this group, send email to solrnet+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/solrnet?hl=en.


Ishanika sivakumar

unread,
Jul 19, 2011, 9:01:47 AM7/19/11
to sol...@googlegroups.com
Hi Mauricio,
Thanks lot.. I am looking exactly the same..
I am just bit struk passing this value on the sample app.

I got it as below
var keywords = Helpers.SCProductHelper.keywordslist(f_groups, "mt");
I got all the keywords in the "keywords"

and defined the Query in list like below:
var _query = new SolrQueryInList("name", keywords);

I am using your sample code to get the result. How to pass the "_query " to solr using below code

var matchingProducts = solr.Query(BuildQuery(parameters), new QueryOptions
{
                FilterQueries = BuildFilterQueries(parameters),
Rows = parameters.PageSize,
Start = start,
OrderBy = GetSelectedSort(parameters),
SpellCheck = new SpellCheckingParameters(),
Facet = new FacetParameters
{
Queries = AllFacetFields.Except(SelectedFacetFields(parameters))
 .Select(f => new SolrFacetFieldQuery(f) { MinCount = 1 })
 .Cast<ISolrFacetQuery>()
 .ToList(),
},
});
Thanks
Siva

Mauricio Scheffer

unread,
Jul 19, 2011, 9:31:56 AM7/19/11
to sol...@googlegroups.com
You can put it in the BuildQuery method or BuildFilterQueries (depending on what you need).

--
Mauricio

Ishanika sivakumar

unread,
Jul 19, 2011, 9:51:53 AM7/19/11
to sol...@googlegroups.com
Hi Thanks Mauricio,
I want it use BuildFilterQueries, but not sure how i can pass this to search parameter
any hep really appreciated..

Thanks
Siva

Siva

unread,
Jul 24, 2011, 8:40:50 AM7/24/11
to SolrNet
Hi,
I have tried with Query by list of values,
The Problem i got , if i search few keywords it works..but
when i search more keyword (around 10 or more) no results i am getting

For ex:
http://localhost:8983/solr/sc4/select/??start=0&rows=10&indent=on&wt=json&q=Bespoke
Shaped || Custom Cut || Custom Shape || Custom Shapes || Custom
Cut || Die Cut || Lenticular || OEM
This query retutns results with out any problem

But when I try with more keywords
http://localhost:8983/solr/sc4/select/?start=0&rows=10&indent=on&wt=json&q=Advent
|| After Dinner Mint || After Dinner Mints || Angel || Bacardi ||
Bag of Nuts || Ballotin || Bauble || Baubles || Church Bell ||
Crystal Bell || Biscuit || Biscuit Tin || Bottle Cooler || Bottle
of Champagne || Bottle Opener || Bottle Stopper || Box of
Chocolates || Brandy || Cake || Champagne Flute || Cheese ||
Chocolate Bar || Chocolate Box || Chocolate Foundue || Chocolate
Fondue || Chocolate Mints || Christmas || Christmas Lights ||
Christmas Tree || Cocktail || Cork Screw || Corkscrew || Cracker
|| Church || Father Christmas || Fir Tree || Fortune Cookies ||
Fruit Cake || Gift Tag || Gin || Greeting Card || Greetings Card
|| Guylian || Hamper || Handmade Chocolate || Handmade Chocolates
|| Holly || Hymns || Ice Bucket || Ice Cube || Inflatable
Microphone || Jesus || Mince Pie || Moet || Mumm || Nativity ||
Neapolitan || Neapolitans || Neopolitan || Neopolitans || Nut
Cracker || Nuts Bag || Nuts Pack || Nuts Tin || Party Lights ||
Pack of Nuts || Party || Peanuts || Plant || Plastic Drink Cup ||
Plastic Glass || Plastic Tumbler || Port Bottle || Bottle of Port
|| Punch Bowl || Reindeer || Rum || Santa || Smoked Salmon ||
Snow || Snow

I am not getting any results...
is any problem on my query?..

Thanks
Siva



On Jul 19, 2:51 pm, Ishanika sivakumar <sivaak...@googlemail.com>
wrote:

Mauricio Scheffer

unread,
Jul 24, 2011, 6:01:20 PM7/24/11
to sol...@googlegroups.com

That's not the correct syntax for boolean operators, see http://lucene.apache.org/java/2_9_1/queryparsersyntax.html#Boolean%20operators for reference.

Ishanika sivakumar

unread,
Jul 25, 2011, 4:01:22 AM7/25/11
to sol...@googlegroups.com
Hi Mauricio..
Thanks for your email,
I have tried with OR as well, but no luck still not returning any result.
http://localhost:8983/solr/sc4/select/?start=0&rows=10&indent=on&wt=json&q=Advent OR After Dinner Mint OR After Dinner Mints OR Angel OR Bacardi OR Bag of Nuts OR Ballotin OR Bauble OR Baubles OR Church Bell OR Crystal Bell OR Biscuit OR Biscuit Tin OR Bottle Cooler


Thanks
Siva

Ishanika sivakumar

unread,
Jul 25, 2011, 4:11:19 AM7/25/11
to sol...@googlegroups.com
Hi Mauricio,
I got ti working ...It is the double quotes,
I need to pass the keywords within quotes i.e q="Advent"  OR "After Dinner Mint"  OR "After Dinner Mints"  OR "Angel"

Thanks for your help...

Regards
Siva
Reply all
Reply to author
Forward
0 new messages