Elastic Search查询[ImageURL]查询错误,查询名称后没有start_object

时间:2019-08-06 11:04:39

标签: elasticsearch

我对ES查询有以下请求JSON。它给了我以下错误:

  

[ImageURL]查询格式错误,查询名称后没有start_object

当我在must_not下添加bool时。如果我删除must_not,它会正常工作。我想获取“ ImageURL”不为空的记录

我在哪里做错了?请帮助

{
        "from": 0,
        "size": 45,
        "query": {
            "bool": {
                "must": {
                    "match_all": {}
                },
                "filter": [
                    [{
                        "term": {
                            "PostStatusInd": 1
                        }
                    }, {
                        "term": {
                            "PostCountry": "PAK"
                        }
                    }], {
                        "range": {
                            "RecModDate": {
                                "gte": "2019-07-07 00:00:00"
                            }
                        }
                    }, {
                        "range": {
                            "PostPriceAmt": {
                                "gte": "0",
                                "lte": "100000000"
                            }
                        }
                    }, {
                        "geo_distance": {
                            "distance": "41000km",
                            "Location": {
                                "lat": "33.6895939",
                                "lon": "73.0435789"
                            }
                        }
                    }
                ],
                "must_not": {
                    "ImageURL": null
                }
            }
        },
        "sort": [{
            "RecModDate": {
                "order": "desc"
            }
        }]
    }

2 个答案:

答案 0 :(得分:0)

you missed writing the term/match function within must_not query

Try the below query

{
        "from": 0,
        "size": 45,
        "query": {
            "bool": {
                "must": {
                    "match_all": {}
                },
                "filter": [
                    [{
                        "term": {
                            "PostStatusInd": 1
                        }
                    }, {
                        "term": {
                            "PostCountry": "PAK"
                        }
                    }], {
                        "range": {
                            "RecModDate": {
                                "gte": "2019-07-07 00:00:00"
                            }
                        }
                    }, {
                        "range": {
                            "PostPriceAmt": {
                                "gte": "0",
                                "lte": "100000000"
                            }
                        }
                    }, {
                        "geo_distance": {
                            "distance": "41000km",
                            "Location": {
                                "lat": "33.6895939",
                                "lon": "73.0435789"
                            }
                        }
                    }
                ],
                "must_not": {
                  "term":{
                    "ImageURL": null
                  }
                }
            }
        },
        "sort": [{
            "RecModDate": {
                "order": "desc"
            }
        }]
    }

答案 1 :(得分:0)

“存在”为我工作

import numpy
import glob, os
import cv2
import os
    input = cv2.imread(path)

    def nothing(x):  # for trackbar
        pass


    windowName = "Image"

    cv2.namedWindow(windowName)
    cv2.createTrackbar("coef", windowName, 0, 25000, nothing)

    condition = True
    while (condition):
        coef = cv2.getTrackbarPos("coef", windowName)
        temp_img = input
        row = temp_img.shape[0]
        col = temp_img.shape[1]
        print(coef)
        red = []
        green = []
        for i in range(row):
            for y in range(col):
               # temp_img[i][y][0] = 0
                temp_img[i][y][1] = temp_img[i][y][1]* (coef / 100)
                temp_img[i][y][1] = temp_img[i][y][2] * (1 - (coef / 100))
                # relative_diff = value_g - value_r

        # temp =cv2.resize(temp,(1000,800))
        cv2.imshow(windowName, temp_img)
        # cv2.imwrite("output2.jpg", temp)
        print("fin")
        # cv2.waitKey(0)
        if cv2.waitKey(30) >= 0:
            condition = False
    cv2.destroyAllWindows()