Multi_match bool query, error

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"
}

Please format your code, logs or configuration files using </> icon as explained in this guide 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:

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.

Thanks dear

What is the error you are getting?

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

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 for some examples.

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"

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.

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