S
S
Stan_12014-07-19 17:22:32
elasticsearch
Stan_1, 2014-07-19 17:22:32

What is the best way to organize a search for multiple fields in ElasticSearch?

Day I fight, but I can not figure out how best to do it. :(
I have an entry like this:
title: "A card for boys"
description: "Children are the flowers of life..."
exist: "Available"
whom: ["To a child", "To a son"]
when: ["February 23rd ", "Birthday"]
Filters are set on all text fields:
"filter": ["lowercase","synonym", "russian_morphology", "my_stopwords"] with a standard tokenizer and Russian morphology
The task is to correctly search for this record in the following queries :
postcard for son
postcard for children
postcard for February 23
postcard for children in stock
The best thing I came up with was to collapse the whom and when arrays into the meta string separated by commas (to also drive words into synonyms and stop words) and do this:
"query": {
"multi_match": {
"query": "postcard for son",
" type": "cross_fields",
"operator": "AND",
"fields" : [ "title^50", "description", "meta^20", "keywords^10", "exist^100" ],
" analyzer": "synonym"
}
}
But if he more or less searches for "postcard for son", then he no longer finds "postcard for son in stock".
How to build such a search in general, or maybe something is fundamentally wrong? Or maybe all the fields in one line can be driven and searched in one field (field)? I searched the Internet for a long time, but did not find anything similar. Many of these things are done through term, but this is only if it is possible to specify a specific search parameter during the search. And I want a free form.
Thank you in advance!!!
UPDATE: I'll clarify how I would see a formalized task. It is necessary to parse the original query into separate words, and, taking into account Russian morphology and synonyms, compare with each of the above fields. Moreover, if the word is not found in any field, then we consider such a request as a whole not relevant to the record. And if every word from the request occurs at least somewhere, then such a record should get into the search results.

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