How to get position of matched token

I want to migrate from Sphinxsearch to Elastic. But have task, that i don't know how to solve in elastic.

I have documents with 2 fields.
First field - "title". It is array of words. And each word can have some synonyms.
Second field - "ids". It is array of ids, corresponding to words on same index.

For example:

title = [ ["word1", "syn11", "syn12"], ["word2", "syn21"], ["word3"] ]
ids = [101, 102, 103]

id = 101 corresponds to word1, 102 - to word2, ...

I need to find documents that match some phrase by field "title". And for that documents get id from "ids" field that corresponds to last matched word. And all that should be done in elastic only (not to use some other applications to process intermediate result).

For example:

  1. match to "word3 syn11" should return 103
  2. match to "word1 syn21" should return 102

In Sphinxsearch I combined all words to string like "word1 syn11 syn12 . word2 syn21 . word3". Then config indexer to process point "." as sentence separator with shifting position on 1000 words. And during search I changed ranking to return maximum position of matched token.

But i there some solution for my task in elastic? I could not find any similar configuration in tokenizers. And only thing I found - I need to write custom plugin to get access to matched token indexes in ranking result.

Help me, please

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.