Spring Data elasticsearch @Query annotation

d8tt03nd  于 5个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(48)

My JSON doc is like this:我的JSON文档如下:

{
"query" : {
    "bool": {
        "minimum_should_match": 1,
        "should": [
        {
          "bool":   { "must": [{"match": {"txt": "p"}},
                    {"match": {"nm": "p"}}
            ]
          }
        },
        {
          "bool": { "must": [{"match": {"txt": "p"}}
            ]
          }
        },
        {
          "bool": { "must": [{"match": {"nm": "p"}}
            ]
          }
        }
        ]
        }
},
"highlight": {
    "number_of_fragments" : 1,
    "order": "score",
    "boundary_scanner": "sentence", 
    "fragment_size" : 300,
    "pre_tags" : ["<tag1>"],
    "post_tags" : ["</tag1>"],
    "fragmenter": "span", 
    "fields" : {
        "nm": {},
        "txt": {}
    }
  },
  "_source": false
}

字符串
How should I write the query method using @Query annotation?(or if there is any other method that I can put the highlight)?我应该如何使用@Query注解编写查询方法?(或者是否有任何其他方法可以突出显示)?
observation:highlight it's very important观察:突出显示它非常重要
Thanks for any suggestion.感谢您的任何建议。

exdqitrt

exdqitrt1#

你应该把查询部分放到@Query注解中,参见相关文档。
对于高亮定义,可以使用@Highlight注解,查看参考文档

相关问题