Search specific field in elastic search

Hi everyone, i want o search records with specific fields in elastic search like records below:

"person": [
	{
		"id": 1
		"name": "jame"
	},
	{
		"id": 2,
		"name": "EVP"
	},
	{
		"id": 3,
		"name": "GP"
	},
	{
		"id": 3,
		"name": "PLR"
     }
]

I want to search id (2 and 3) in the person, i have tried query_string but it's not working, my code is as below:

{
    "query" : {
        "query_string" : {
            "default_field" : "person.id",
            "query" : "2, 3"
        }
    }
}

And i also try to use another way, but i always get error with NumberFormatException.

Can anyone help me?
Thanks

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

Don't paste images if not useful. Better to paste the full error in your case so it's searchable.

The short answer is that you probably should use a bool query and should or must or filter clauses.

But I don't understand the model here TBH. What are you searching for? This group of persons or just individuals?

If the later, then index them one by one. One person per document.
Then if you just want to GET by id a person run:

GET person/doc/1

And you're done.

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