Es 5.1.1 [match_all] query malformed, no start_object after query name


(Lorenzo) #1

Hi to everybody,

I'm trying to convert a query, written for ElasticSearch 2, to ElasticSearch 5.1.1.

Es 2

 {
    	"index": "wsx5_answers",
    	"type": "topics",
    	"body": {
    		"fields": ["title"],
    		"query": {
    			"filtered": {
    				"query": {
    					"match_all": []
    				},
    				"filter": {
    					"bool": {
    						"must": [{
    							"terms": {
    								"status": ["approved"]
    							}
    						}, {
    							"terms": {
    								"type": ["question", "idea", "praise", "update", "info", "bug", "faq", "tipsandtricks"]
    							}
    						}, {
    							"term": {
    								"author": 12345
    							}
    						}, {
    							"bool": {
    								"should": [{
    									"term": {
    										"public": true
    									}
    								}, {
    									"term": {
    										"author": 12345
    									}
    								}]
    							}
    						}, {
    							"terms": {
    								"lang": ["it"]
    							}
    						}]
    					}
    				}
    			}
    		},
    		"size": 15,
    		"from": 0,
    		"sort": {
    			"lastupdate": {
    				"order": "desc"
    			}
    		}
    	}
    }

Es 5.1.1

{
	"index": "wsx5_answers",
	"type": "topics",
	"body": {
		"stored_fields": ["title"],
		"query": {
			"bool": {
				"must": {
					"match_all": []
				},
				"filter": {
					"bool": {
						"must": [{
							"terms": {
								"status": ["approved"]
							}
						}, {
							"terms": {
								"type": ["question", "idea", "praise", "update", "info", "bug", "faq", "tipsandtricks"]
							}
						}, {
							"term": {
								"author": 12345
							}
						}, {
							"bool": {
								"should": [{
									"term": {
										"public": true
									}
								}, {
									"term": {
										"author": 12345
									}
								}]
							}
						}, {
							"terms": {
								"lang": ["it"]
							}
						}]
					}
				}
			}
		},
		"size": 15,
		"from": 0,
		"sort": {
			"lastupdate": {
				"order": "desc"
			}
		}
	}
}

Always rise this exception:

[match_all] query malformed, no start_object after query name

I tried to remove "bool" under "filter", but nothing change.

I use ElastSearch PHP Client.

Someone can help me?


(David Pilato) #2

"match_all": [] should be "match_all": {}


(Lorenzo) #3

Thank you very much!


(system) #4

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