Pregunta

I try to search with Sphinx

search --index goods "new @category_id 711"

ends with search error because of "@category_id 711" but it should be correct way, how search in exact column see http://sphinxsearch.com/docs/current.html#extended-syntax

but in sphinx.conf is

 sql_query = SELECT id, name, category_id FROM ...

 sql_attr_uint = category_id

and don't want set

 $sphinx->setFilter('category_id', array(711), false);

bucause it limit result only for category 711

I need add weight to category_id, and search rest of text in name

$sphinx->SetFieldWeights(array('name' => 1000, 'category_id' => 250));

but searching of "711" should not be in "name"

¿Fue útil?

Solución

Few things going on here!

'search' commands default search mode, is not extended. So if you use extended syntax, have to specifically enable extended mode. add -e


In your config file you've made it an Attribute. Attributes are NOT accessible in the @field syntax. ie they are NOT full text indexed, so you cant query by them.

So if want it in the search query, need to make a field. (not an attribute).


Then can do a query new @category_id 711 - but that means the query must match new AND @category_id 711, so it will behave exactly the same as the setFilter.

If you just want to "promote" that category, need to rearrange the query, so that it will only match on 'new', but the category bit is included, so that you can then influence the ranking

(new) | (new @category_id 711)

for example.

But then you also need to change the RANKING mode, so that it will change the ranking. Experment with the various modes to decide which you like. SPH_RANKING_WORDCOUNT, is the most basic, but might not be good enough.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top