K
K
Kola2014-11-28 16:00:56
Sphinx
Kola, 2014-11-28 16:00:56

How to create snippets in delta indexes?

Good afternoon.
I'm trying to implement delta indexes in my application.
The original config was:

index search_content {
     # config
}

Requests to it went like
SELECT * FROM search_content WHERE MATCH('@(header, body) "test"');

Then I added a delta:
index search_content {
     # config
}

index search_content_delta : search_content {
     # config
}

Now, to search in the full index (main + delta), you need to search in both indexes at once:
SELECT * FROM search_content, search_content_delta WHERE MATCH('@(header, body) "test"');

But in order to make it easier for myself and for the sake of this not to add the name of the index delta to the requests in the application code, I renamed the main index, made a composite index from the main and delta index and named it like the old main index - search_content:
index search_content_main {
     # config
}

index search_content_delta : search_content_main {
     # config
}

index search_content {
  local = search_content_main
  local = search_content_delta
}

Now, despite the fact that the queries to the sphinx remained unchanged
SELECT * FROM search_content WHERE MATCH('@(header, body) "test"');

sphinx perfectly returns data from both indexes in one query: main and delta.
However, when trying to compile snippets via CALL SNIPPETS from this composite index, the sphinx swears:
[1064] The distributed index for snippets must have exactly one local agent [ CALL SNIPPETS(('test string text'), 'search_content', 'test' ,'<b>' as `before_match`,'</b>' as `after_match`)]

Apparently, composite indexes from multiple local indexes are not supported in snippets.
Listing indexes separated by commas in CALL SNIPPETS also gives an error, the syntax does not allow.
I couldn't find anything on this topic in the documentation.
Actually the question is: is it possible to compose snippets with one request from the main and delta index? It doesn't matter if it's through composite indexes or something else.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Panov, 2014-11-28
@LDZ

Good afternoon.
Snippets work a little differently than you imagine. The index is necessary to you only what to take morphology of processing of lines. You pass the strings themselves to the CALL SNIPPETS function. So it will be enough for you to use only the main index to get the morphology.
Example from the docs:
CALL SNIPPETS('this is my document text', 'test1', 'hello world')
The documentation says:
"It could be a single string, or the list of the strings enclosed in curly brackets. index is the name of the index from which to take the text processing settings. query is the full-text query to build snippets for."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question