D
D
Drum Kit2015-07-06 19:43:17
Search Engine Optimization
Drum Kit, 2015-07-06 19:43:17

How to search all words in a field in elasticsearch?

I have such a problem, for example, I have the text "hello world" and I need to return those documents in which there are 2 words and not "hello" or "world"

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kotofey, 2015-07-06
@kotofey

This is implemented using phrase search :

GET /megacorp/employee/_search
{
    "query" : {
        "match_phrase" : {
            "some_field" : "hello world"
        }
    }
}

U
un1t, 2015-07-07
@un1t

{
    "match" : {
        "message" : {
            "query" : "hello world",
            "operator" : "and"
        }
    }
}

G
gulitskiy, 2015-08-05
@gulitskiy

the answer from un1t searches for words throughout the text, regardless of their location, the main thing is that they are, and if analyzers with morphology, then there will also be word forms to look for
recently did to search for a phrase but with word forms, asked the question
How to search for phrases in elasticsearch with fuzzy?
applies only to such a configuration of analyzers as in the question, you need to test for another

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question