Hello,
I've just started using Elastic and my use case involves retrieving relevant documents using a natural query string and the following query:
{
"size": "5",
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "<Query string>",
"type": "most_fields",
"fields": [
"text"
]
}
}
]
}
}
}
I need to make this query more powerful in the following way:
Some documents that exceed a certain word length also have a field called "chunks". This field contains a list of sublists, where each sublist contains two integers that correspond to the start character and end character of several substrings found in the srting contained in the "text" field.
For example:
chunks: [ [ 0, 1278], [537, 1802], [1127, 2388],... ]
Also it should be mentioned that, as you can see in this example, the chunks are overlapping.
I need the above query to first hit the top N documents and then for each one, IF it has the field "chunks", map each chunk to the corresponding text using the "text" field and return the top 1-2 chunks that match my query string INSTEAD of the "text" field. Otherwise, if the "chunks" field is not found, return the "text" field.
Is this possible? And if it is, how to approach this? Thanks!