Hi Steve, No. My cat2_facet field does not have id number. In the 2 queries below... not sure why query 1 did not work and query 2 worked perfectly.
1) query 1 (should return 2 documents, but it did not work) webapp=/solr path=/select params={facet=true&fl=pk_i,score&facet.mincount=1&q=([*+TO+*]+AND+* cat2_facet:Top+Wear*)+AND+(type_s:Item)&facet.limit=-1&facet.field=cat1_facet&facet.field=cat2_facet&qt=standard&wt=ruby} *hits=0* status=0 QTime=10 2) query 2 (worked. did return 2 documents) webapp=/solr path=/select params={facet=true&fl=pk_i, score&facet.mincount=1&q=([*+TO+*]+AND+*cat2_facet:Shoes*)+AND+(type_s:Item)&facet.limit=-1&facet.field=cat1_facet&facet.field=cat2_facet&qt=standard&wt=ruby} *hits=2* status=0 QTime=1 Have you ever used a string facet field in which the facet value contains 2 or more words like Brand:Hewlett Packard If yes, what the query looks like exactly to filter the results based on the facet value = 'Hewlett Packard'? Thanks. Thanh On Fri, Jun 5, 2009 at 10:09 PM, Stephen Weiss <swe...@stylesight.com>wrote: > Thanh, > > Do the categories have id numbers? What we do is we index the ID numbers > of our tags and categories, and then on display we pull the real text out of > the database. In our situation, since the tags and categories are > multilingual, it's a lot easier than converting from English to the other > language where conflicts in encoding can arise. The advantage is, the id > number never has a space or any special character, so it always works. > > Another quick and dirty option might be to index the field as type "string" > - but then you probably want to do this with a copyField since it'll make it > more cumbersome to search through with a text query. I haven't tried this > though so I'm not sure. > > -- > Steve > > > On Jun 5, 2009, at 9:00 PM, Thanh Doan wrote: > > I used latest acts_as_solr to index a number of sample 'sale' items. >> Those item documents has a facet field, Its name is cat2_facet. >> >> There are a number of documents that have cat2_facet= "Shoes" and >> There are a number of documents that have cat2_facet= "*Top Wear*". The >> problem is the space between *Top and Wear*. >> >> results = Item.find_by_solr("[* TO *]", >> {:facets=>{:zeros=>false,:fields=>[:cat1, :cat2] }}) >> results.facets["facet_fields"] >> >> return {"cat1_facet"=>{"electronics"=>5, "clothing"=>5}, >> *"cat2_facet"=>{"Bottom >> Wear"=>1, "Top Wear"=>2*, "Shoes"=>2, "HDTV"=>1, "Camera"=>4}} >> >> When I issue the query below >> >> results = Item.find_by_solr("[* TO *] AND cat2:Shoes", >> {:facets=>{:zeros=>false,:fields=>[:cat1, :cat2] }}) >> >> It returned correct number of hits. However when i run the query >> >> results = Item.find_by_solr("[* TO *] AND cat2:*Top Wear*", >> {:facets=>{:zeros=>false,:fields=>[:cat1, :cat2] }}) >> >> It return zero hit (incorrect). >> >> I even tried to put quote and double quote for the facet value >> >> @results = Item.find_by_solr("[* TO *] AND cat2:'*Top Wear'*", >> {:facets=>{:zeros=>false,:fields=>[:cat1, :cat2] }}) >> >> And it still does not work. What should I do to remedy this space issue? >> >> Let me also attach the translated solr query I saw in solr log file >> >> INFO: [] webapp=/solr path=/select >> >> params={facet=true&fl=pk_i,score&facet.mincount=1&q=([*+TO+*]+AND+cat2_facet:Shoes)+AND+(type_s:Item)&facet.limit=-1&facet.field=cat1_facet&facet.field=cat2_facet&qt=standard&wt=ruby} >> *hits=2* status=0 QTime=1 >> >> Jun 5, 2009 7:54:23 PM org.apache.solr.core.SolrCore execute >> >> INFO: [] webapp=/solr path=/select >> >> params={facet=true&fl=pk_i,score&facet.mincount=1&q=([*+TO+*]+AND+cat2_facet:Top+Wear)+AND+(type_s:Item)&facet.limit=-1&facet.field=cat1_facet&facet.field=cat2_facet&qt=standard&wt=ruby} >> *hits=0* status=0 QTime=10 >> >> Thank you. >> Thanh >> > >