S
S
smigles2021-11-11 19:02:35
Sphinx
smigles, 2021-11-11 19:02:35

How to implement a multi-value field in Sphinx?

There is an index which is formed through xmlpipe. His docs have a full text field that should collect multiple values. Each value is one word.

Currently the data source looks like this:

<sphinx:docset>
    <sphinx:schema>
        <sphinx:field name="words"/>
    </sphinx:schema>
    <sphinx:document id="1">
        <words>слово1 слово2 слово3</words>
    </sphinx:document>
    ...
</sphinx:docset>


That is, words are combined into one line through a separator, such as a space.

The problem with this solution is that combining values ​​in this way is bad for search relevancy. Let's imagine that the field looks like this: слово1 слово2 слово3. If we are looking for слово1, then Sphinx will assume that the query does not exactly match the value of the field. Accordingly, the position of such a document in terms of relevance will be lower than that of a document with a field of one word: слово1.

Is there a better way to implement a field with multiple values? It should turn out something like this:
<sphinx:docset>
    <sphinx:schema>
        <sphinx:field name="words"/>
    </sphinx:schema>
    <sphinx:document id="1">
        <words>слово1</words>
        <words>слово2</words>
        <words>слово3</words>
    </sphinx:document>
    ...
</sphinx:docset>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question