Elasticsearch查询-Match Query
来源:互联网 发布:数据库索引原理 编辑:程序博客网 时间:2024/04/29 11:13
新建索引数据
PUT /_bulk{ "index" : { "_index" : "students", "_type" : "student", "_id" : "1" } }{ "name" : "瑞文" ,"age":9,"grade":"三年级","class":"1班"}{ "index" : { "_index" : "students", "_type" : "student", "_id" : "2" } }{ "name" : "瑞兹" ,"age":8,"grade":"三年级","class":"2班"}{ "index" : { "_index" : "students", "_type" : "student", "_id" : "3" } }{ "name" : "男刀" ,"age":9,"grade":"三年级","class":"3班"}{ "index" : { "_index" : "students", "_type" : "student", "_id" : "4" } }{ "name" : "女刀" ,"age":8,"grade":"三年级","class":"1班"}{ "index" : { "_index" : "students", "_type" : "student", "_id" : "5" } }{ "name" : "蜘蛛" ,"age":9,"grade":"三年级","class":"2班"}{ "index" : { "_index" : "students", "_type" : "student", "_id" : "6" } }{ "name" : "挖掘机" ,"age":8,"grade":"三年级","class":"3班"}{ "index" : { "_index" : "students", "_type" : "student", "_id" : "7" } }{ "name" : "劫" ,"age":9,"grade":"三年级","class":"1班"}{ "index" : { "_index" : "students", "_type" : "student", "_id" : "8" } }{ "name" : "乐芙兰" ,"age":8,"grade":"三年级","class":"2班"}{ "index" : { "_index" : "students", "_type" : "student", "_id" : "9" } }{ "name" : "狐狸" ,"age":9,"grade":"三年级","class":"2班"}{ "index" : { "_index" : "students", "_type" : "student", "_id" : "10" } }{ "name" : "盖伦" ,"age":8,"grade":"三年级","class":"3班"}
查询的json:
{ "match" : { "name" : { "query" : " 狐狸", "type" : "boolean" } }}
java-api
QueryBuilder queryBuilder = QueryBuilders.matchQuery( "name", " 狐狸" ); SearchResponse searchResponse = client.prepareSearch("students").setTypes("student").setQuery(queryBuilder).execute().actionGet(); SearchHits searchHits = searchResponse.getHits(); SearchHit[] hits = searchHits.getHits(); for (SearchHit searchHitFields : hits){ System.out.println(searchHitFields.getSource()); }
结果如下:
{grade=三年级, name=狐狸, class=2班, age=9}
2 0
- Elasticsearch查询-Match Query
- Elasticsearch查询之Match
- ElasticSearch查询match
- elasticsearch 查询match和term
- Elasticsearch Span Query跨度查询
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)【转载】
- Elasticsearch查询match、term和bool区别
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- 互联网MySQL开发规范
- 6.0默认打开数据开关
- python分解质因数
- svn安装及使用
- FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask.
- Elasticsearch查询-Match Query
- virtualbox 下centos7配置
- 深入分析noedjs爬虫中出现的乱码情况
- C#扩展方法
- PHP array_walk函数用法
- Python进阶(二十六)-多线程实现同步的四种方式
- mini2440 nand flash驱动移植--问题解决记录
- cas4.2x学习
- C#程序结构