Elasticsearch: fetching match_phrase from a document in an index


#1

Elasticsearch docs gives an example of how to build a search query with terms that can reside in a document and fetched from an index like below

GET /tweets/_search
{
    "query" : {
        "terms" : {
            "user" : {
                "index" : "users",
                "type" : "_doc",
                "id" : "2",
                "path" : "followers"
            }
        }
    }
}

Is it possible to do this with match_phrase instead of terms? The below raises a parsing exception. What I am trying to do is to search a text field with a large number of phrase terms. Is it is not possible what is the best way to achieve its equivalent?

GET /tweets/_search
{
    "query" : {
        "match_phrase" : {
            "user" : {
                "index" : "users",
                "type" : "_doc",
                "id" : "2",
                "path" : "followers"
            }
        }
    }
}

(system) #2

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