Question: I am new to Elastic search . Please help me in finding the filter/query to be written to match the exact records using Java API.

```
Below is the mongodb record .I need to get both the record matching the word 'Jerry' using elastic search.

{
        "searchcontent" : [
                {
                        "key" : "Jerry",
                        "sweight" : "1"
                },{
                        "key" : "Kate",
                        "sweight" : "1"
                },

        ],
        "contentId" : "CON_4",
        "keyword" : "TEST",
        "_id" : ObjectId("55ded619e4b0406bbd901a47")
},
{
        "searchcontent" : [
                {
                        "key" : "TOM",
                        "sweight" : "2"
                },{
                        "key" : "Kruse",
                        "sweight" : "2"
                }

        ],
        "contentId" : "CON_3",
        "keyword" : "Jerry",
        "_id" : ObjectId("55ded619e4b0406ccd901a47")
}

```

Answer: 
A [Multi-Match](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) query is what you need to search across multiple fields. Below query will search for the word "jerry" in both the fields "searchcontent.key" and "keyword" which is what you want.

```
POST <index name>/<type name>/_search
{
   "query": {
      "multi_match": {
         "query": "jerry",
         "fields": [
            "searchcontent.key",
            "keyword"
         ]
      }
   }
}

```
There is no single solution, it depends how you map your data in elastic search and what you are indexing

GET /intu/\_settings

You can use: **query string**.

If you don't need to combine filter you can remove bool and should.

From the documentation: *"The bool query takes a more-matches-is-better approach, so the score from each matching must or should clause will be added together to provide the final \_score for each document."*

For example:

```
GET /yourstaff/_search
{
"query": {
  "filtered": {
     "query": {
        "bool": {
           "should":
              {
                 "query_string": {
                    "query": "jerry"
                 }
              }
        }
     }
  }
 }
}

```

Take a look to the documentation:

* [Query string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax "Query string")
* [Term vs full-search](https://www.elastic.co/guide/en/elasticsearch/guide/current/term-vs-full-text.html)
* [Bool query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

Use [Sense](https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig?hl=en) to figure out what results you want to have