在Elasticsearch中从json访问嵌套对象

时间:2018-08-03 10:28:03

标签: elasticsearch

我正在编写一个搜索查询,要求我访问出发对象“ city”的属性

  public  List<Map<String, Object>> ff(int minPrice, int maxPrice, String city) {
        List<Map<String, Object>> search = new ArrayList<>();


        QueryBuilder range = QueryBuilders.rangeQuery("price")
                .from(minPrice)
                .to(maxPrice)
                .includeLower(true)
                .includeUpper(true);

        QueryBuilder cityQuery = QueryBuilders.matchQuery("departure.city", city);

        QueryBuilder query = QueryBuilders.boolQuery()
                .filter(range)
                .filter(cityQuery);

当我尝试为我肯定存在于数据中的城市进行数据查询时,我会得到空结果

下面是我的索引

{
    "tourdata": {
        "aliases": {},
        "mappings": {
            "tours": {
                "properties": {
                    "departure": {
                        "properties": {
                            "city": {
                                "type": "text",
                                "fields": {
                                    "keyword": {
                                        "type": "keyword",
                                        "ignore_above": 256
                                    }
                                }
                            },
                            "date": {
                                "type": "date"
                            }
                        }
                    },

0 个答案:

没有答案