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

Reply via email to