term查询
来源:互联网 发布:淘宝店如何增加销量 编辑:程序博客网 时间:2024/05/17 22:58
# term查询# term查询:查询某字段里有某个关键词的文档GET /library/books/_search{ "query": { "term": { "preview": "elasticsearch" } }}{ "took": 12, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 3, "max_score": 0.15372275, "hits": [ { "_index": "library", "_type": "books", "_id": "2", "_score": 0.15372275, "_source": { "title": "The Elasticsearch cookbook", "price": 15, "preview": "One of the main requirements of today's applications is search capability. In the market, we can find a lot of solutions that answer this need, both in commercial as well as the open source world. One of the most used libraries for searching is Apache Lucene. This library is the base of a large number of search solutions such as Apache Solr, Indextank, and ElasticSearch.", "publish_date": "2015-05-12" } }, { "_index": "library", "_type": "books", "_id": "1", "_score": 0.125, "_source": { "title": "Elasticsearch: The Definitive Guide", "price": 5, "preview": "Elasticsearch is a distributed, scalable, real-time search and analytics engine. It ena‐bles you to search, analyze, and explore your data, often in ways that you did not anticipate at the start of a project. It exists because raw data sitting on a hard drive is just not useful.", "publish_date": "2015-02-08" } }, { "_index": "library", "_type": "books", "_id": "3", "_score": 0.033562027, "_source": { "title": "Elasticsearch Blueprints", "price": 9, "preview": "This book starts with the creation of a Google-like web search service, enabling you to generate your own search results. You will then learn how an e-commerce website can be built using Elasticsearch. We will discuss various approaches in getting relevant content up the results, such as relevancy based on how well a query matched the text, time-based recent documents, geographically nearer items, and other frequently used approaches.", "publish_date": "2015-06-01" } } ] }}[elk@node01 api]$ cat a11.pl ##发送消息use LWP::UserAgent; use LWP;use Encode;use LWP::Simple;use LWP::UserAgent;use HTTP::Cookies;use HTTP::Headers;use HTTP::Response;use Encode;use URI::Escape;use URI::URL;use JSON;use Data::Dumper; my $ua = LWP::UserAgent->new; $ua->agent("Mozilla/5.0 (Windows NT 6.1; rv:30.0) Gecko/20100101 Firefox/30.0"); my $cookie_jar = HTTP::Cookies->new( file=>'lwp_cookies.txt', autosave=>1, ignore_discard=>1); $ua->cookie_jar($cookie_jar); my $login_url ="http://192.168.137.2:9200/library/books/_search"; my $post ={ "query" => { "term" => { "preview" => "elasticsearch" } }}; use JSON qw(encode_json); $json_string = encode_json($post); my $req = HTTP::Request->new( 'GET' => $login_url ); $req->content_type('application/json; charset=UTF-8') ; #post请求,如果有发送参数,必须要有这句 $req->content("$json_string"); #发送post的参数 my $res = $ua->request($req); print $res->content()."\n"; #获取的是响应正文 [elk@node01 api]$ perl a11.pl {"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":3,"max_score":0.15372275,"hits":[{"_index":"library","_type":"books","_id":"2","_score":0.15372275,"_source":{ "title":"The Elasticsearch cookbook","price":15,"preview":"One of the main requirements of today's applications is search capability. In the market, we can find a lot of solutions that answer this need, both in commercial as well as the open source world. One of the most used libraries for searching is Apache Lucene. This library is the base of a large number of search solutions such as Apache Solr, Indextank, and ElasticSearch.", "publish_date":"2015-05-12" }},{"_index":"library","_type":"books","_id":"1","_score":0.125,"_source":{ "title":"Elasticsearch: The Definitive Guide","price":5,"preview":"Elasticsearch is a distributed, scalable, real-time search and analytics engine. It ena‐bles you to search, analyze, and explore your data, often in ways that you did not anticipate at the start of a project. It exists because raw data sitting on a hard drive is just not useful." ,"publish_date":"2015-02-08"}},{"_index":"library","_type":"books","_id":"3","_score":0.033562027,"_source":{ "title":"Elasticsearch Blueprints","price":9,"preview":"This book starts with the creation of a Google-like web search service, enabling you to generate your own search results. You will then learn how an e-commerce website can be built using Elasticsearch. We will discuss various approaches in getting relevant content up the results, such as relevancy based on how well a query matched the text, time-based recent documents, geographically nearer items, and other frequently used approaches." , "publish_date":"2015-06-01"}}]}}
阅读全文
0 0
- term查询
- solr term 查询
- Elasticsearch Term查询
- ES查询term的用法
- elasticsearch 查询match和term
- solr :term 查询, phrase查询, boolean 查询
- Elasticsearch5中term 查询和match 查询
- Term
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- lucene Direction类 和 term查询
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- elasticsearch 查询(match和term)
- java 如何跳出指定的for循环
- 获取传入月份的最后一天
- 【Jsoup in action】模拟浏览器:post方式模拟登陆获取网页数据(二)
- centos:mysql更改密码和设置远程登录,更改默认字符
- mac node 安装
- term查询
- js执行上下文
- UIColor+Hex
- oracle 测试窗口批量删除
- getPropertyValue
- JAVA方法SQL语句执行顺序
- python 正常运行 打包exe出错
- 类间数据量不均衡
- 【mysql】用户管理