Mangoski
Mangoski

Reputation: 2119

Elasticsearch query to search two word combination with space

I have a elasticsearch query to search the data based on name.

My query is

$http.post(elasticSearchURL,{ "filter": { "and": [{ "term": { "Name": "allan" } } ] } })

The above query works fine for single word search but when I give two words with space it doesn't picks any data for it.

My query is not working for below scenario.

{ "filter": { "and": [{ "term": { "Name": "allan edward" } } ] } }

I dont know what keyword should I have to append to satisfy my search scenario.

Thanks in advance

Upvotes: 1

Views: 4579

Answers (1)

Vineeth Mohan
Vineeth Mohan

Reputation: 19253

Phrase match query is what you are looking for.

A query like below should work fine -

{
    "query": {
        "match_phrase": {
            "title": "allan edward"
        }
    }
}

Upvotes: 7

Related Questions