# Multi\_match bool query, error

**URL:** <https://discuss.elastic.co/t/multi-match-bool-query-error/134620>\
**Category:** Elasticsearch\
**Created:** [June 5, 2018, 12:56pm UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620 "2018-06-05T12:56:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![matteo.lavaggi](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@matteo.lavaggi](https://discuss.elastic.co/u/matteo.lavaggi)\
**Post date:** [June 5, 2018, 12:56pm UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620/1 "2018-06-05T12:56:26Z")

</div>

Hi dear, any one can tell me where is the mistake in this sintax? i'm tryng to query different fields with different match type to get better result with no luck

```
{
	"_source": 
	{

	},
  "query": {
    "bool": {
      "should": [
        {
          "multi_match": {
			"query": "||SEARCH_QUERY||",
			"fields": 
			[
				"0": "pname",
			],
			"type": "best_fields",
			"operator": "AND",
			"fuzziness": "auto"
		}
        },
        {
          "multi_match": {
			"query": "||SEARCH_QUERY||",
			"fields": 
			[
				"1": "shortdesc^2"		
			],
			"type": "most_fields",
			"operator": "OR",
			"minimum_should_match": "80%",
			"fuzziness": "auto"
		}
        },
		{
          "multi_match": {
			"query": "||SEARCH_QUERY||",
			"fields": [ 
			
			    "2": "feature",
				"3": "ref",
                "4": "mname",
                "5": "cname",
				"6": "shortdesc",		
				"7": "sref",				
				"8": "ean13"
			],
			"type": "cross_fields",
			"operator": "AND",
			"fuzziness": "auto"
		}
        }
		
      ]
    }
  },
"from": "0",
"size": "200"
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 5, 2018, 1:07pm UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620/2 "2018-06-05T13:07:36Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

---

<div class="post-metadata">

**Author:** ![matteo.lavaggi](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@matteo.lavaggi](https://discuss.elastic.co/u/matteo.lavaggi)\
**Post date:** [June 5, 2018, 1:52pm UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620/3 "2018-06-05T13:52:04Z")

</div>

Thanks dear

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 5, 2018, 3:00pm UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620/4 "2018-06-05T15:00:13Z")

</div>

What is the error you are getting?

---

<div class="post-metadata">

**Author:** ![matteo.lavaggi](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@matteo.lavaggi](https://discuss.elastic.co/u/matteo.lavaggi)\
**Post date:** [June 5, 2018, 5:24pm UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620/5 "2018-06-05T17:24:57Z")

</div>

I have no access to es log error on the software installed, but we get empty search result ! I only can check server side log if can help

---

<div class="post-metadata">

**Author:** ![Magnus\_Kessler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnus_kessler/32/42001_2.png) [@Magnus\_Kessler](https://discuss.elastic.co/u/Magnus_Kessler)\
**Post date:** [June 5, 2018, 9:12pm UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620/6 "2018-06-05T21:12:46Z")

</div>

The `"fields": []` arrays must only contain a list with the names of the fields on which the "query" is run. You're trying to use object syntax inside of the arrays. Also make sure there aren't any stray commas. See the [`multi_match` query documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) for some examples.

---

<div class="post-metadata">

**Author:** ![matteo.lavaggi](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@matteo.lavaggi](https://discuss.elastic.co/u/matteo.lavaggi)\
**Post date:** [June 6, 2018, 6:45am UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620/7 "2018-06-06T06:45:52Z")

</div>

Hi, thanks, the original app config use these syntax:

```
{
	"_source": 
	{

	},
	"query": 
	{
		"multi_match": 
		{
			"query": "||SEARCH_QUERY||",
			"fields": 
			{
				"0": "pname^50",
                                "1": "feature^5",
				"2": "ref^10",
                                "3": "mname^10",
                                "4": "cname^5",
				"5": "shortdesc^2",		
				"6": "sref^8",				
				"7": "ean13^1"
			},
			"type": "cross_fields",
			"operator": "AND",
			"minimum_should_match": "80%",
			"fuzziness": "auto"
		}
	},
	"from": "0",
	"size": "200"
},

```

And this work "great"

---

<div class="post-metadata">

**Author:** ![Magnus\_Kessler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnus_kessler/32/42001_2.png) [@Magnus\_Kessler](https://discuss.elastic.co/u/Magnus_Kessler)\
**Post date:** [June 6, 2018, 8:31am UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620/8 "2018-06-06T08:31:15Z")

</div>

The example you show there obviously uses object syntax instead of array syntax. I guess that in this case the code iterates over the values of the key value pairs.

If my understanding of `multi_match` is correct, then you can do away with the key names such as `"0"` and `"1"`, and simply use a list of the values (`["pname^50", "feature^5"]`) instead.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 4, 2018, 8:31am UTC](https://discuss.elastic.co/t/multi-match-bool-query-error/134620/9 "2018-07-04T08:31:18Z")

</div>

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