Sphinx Thinking: Querying Only Specific Fields in Model Index

Recently, many have asked me about the Sphinx. Here is another one:

In some of my searches, I would like to request only some of the fields included in my index definition. It seems that I can not find anything in this, the closest that limits the global search to specific models.

So, is it possible to query only a given subset of fields in an index?

+4
source share
4 answers

This is possible through the Sphinx extended matching syntax :

Model.search "@ (name, description) ruby ​​pancakes" ,: match_mode =>: extended

If the name and description are the fields you are looking for, and "ruby pancakes" is a search query.

+8
source

Now that Sphinx v3 is missing, the documentation says that advanced mode is enabled by default, so you just need to do something like:

Model.search "@(name,description) ruby pancakes" 
+3
source

Not sure about Thinking Sphinx, but I know, if you click Sphinx directly through SphinxQL, than you can specify the fields you want to map.

I would be surprised if TS did not provide you this function ...

+1
source

I haven’t worked with TS for a while, but I remember you could create a separate index that includes a subset of the fields that you use in your main index. I do not think that Sphinx distinguishes the fields that you use to create the index, because you use a full-text search engine - to search for content on several fields at once.

So, just check how to create a new index with other fields and how to use this new index, not the default.

+1
source

Source: https://habr.com/ru/post/1369393/


All Articles