0

How do I create a query to search for "TV antenna" in Elasticsearch that would return only the first object?

{
    "name": "First",
    "categories": ["Medium TV antennas and cables", "TV cables"]
},
{
    "name": "Second",
    "categories": ["antennas and cables", "TV and accessories"]
}

Could anyone assist?

2 Answers 2

1

Try this one:

curl -XGET 'localhost:9200/indexxx/topic/_search?pretty=true' -d '{
  "query": {
    "match": {
      "categories": {
        "query": "TV antenna",
        "operator": "and"
      }
    }
  }
}'
Sign up to request clarification or add additional context in comments.

Comments

0

Use a phrase match query:

{
    "query": {
        "match_phrase": {
            "categories": {
                "query": "TV antennas"
            }
        }
    }
}

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/phrase-matching.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.