Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AWS by (19.1k points)

I have pushed JSON documents like below:

{

"Apartment_Area": "kengeri",

 "Apartment_bhk": "2bhk",

 "Apartment_owner": "yuvraj",

 "Apartment_forSale": "sold_out"

}

{

 "Apartment_Area": "madiwala",

 "Apartment_bhk": "1bhk",

 "Apartment_owner": "yuvraj",

 "Apartment_forSale": "for_sale"

}

now I am trying to search both 1bhk and 2bhk from an elastic search using below query it gives me both 1bhk and 2bhk of JSON data.

/_search?pretty&q=1bhk,2bhk

Now I am trying to fetch 1bhk with the name yuvraj, which mean I only want to see the data of 1bhk who's name is yuvraj.

what would be the query for this any idea?

1 Answer

0 votes
by (44.3k points)

Found the answer from this Documentation - Finding Multiple Exact Values

Try a POST to /_search?pretty with this body provided below:

{

    "query" : {

        "constant_score" : {

            "filter" : {

                "terms" : {

                    "Apartment_bhk" : ["1bhk", "2bhk"]

                }

            }

        }

    }

}

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

+2 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...