码迷,mamicode.com
首页 > 其他好文 > 详细

Elasticsearch 邻近查询示例

时间:2015-03-05 16:37:00      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

Elasticsearch 邻近查询示例
JAVA API方式:
技术分享
1 SpanNearQueryBuilder span = QueryBuilders.spanNearQuery();
2 span.clause(QueryBuilders.spanTermQuery("Text", "学"));
3 span.clause(QueryBuilders.spanTermQuery("Text", "联"));
4 span.inOrder(true).slop(1);
5 SearchRequestBuilder rs = client.prepareSearch("weiboall")
6                 .setQuery(span).setFrom(0).setSize(20);
7 SearchResponse response = rs.get();
ES 邻近查询JavaAPI
REST方式(JSON):
技术分享
 1 {
 2   "from": 0,
 3   "size": 20,
 4   "query": {
 5     "span_near": {
 6       "clauses": [
 7         {
 8           "span_term": {
 9             "Text": {
10               "value": "在"
11             }
12           }
13         },
14         {
15           "span_term": {
16             "Text": {
17               "value": "讨"
18             }
19           }
20         }
21       ],
22       "slop": 0,
23       "in_order": true
24     }
25   }
26 }
JSON邻近查询

 

Elasticsearch 邻近查询示例

标签:

原文地址:http://www.cnblogs.com/tianjixiaoying/p/4316071.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!