Elasticsearch.The.Definitive.Guide学习笔记 -- 1. You know, for search

http://localhost:9200/?pretty 
http://localhost:5601/app/marvel
http://localhost:9200/_plugin/head/


1 请求格式

curl  -i  -X<VERB> '<PROTOCOL>://<HOST>/<PATH>?<QUERY_STRING>'  -d '<BODY>'


VERB : GET POST HEAD DELETE PUT

PROTOCOL : http / https

HOST : 127.0.0.1:9200 (例子)

PORT : 端口号9200

QUERY_STRING : 查询参数 _count _search

BODY : json串

'{
    "query": {
        "match_all":{}
    }
}'

2  与关系型数据库对比

Relational DB  -> Databases   -> Tables  -> Rows  ->  Columns
ElasticSearch  ->    Indices  (目录)   ->  Types  ->  Documents -> Fields 

3 http://127.0.0.1:9200/megacorp/employee/_search?q=last_name:Smith
 megacorp : index (目录)
 employee : type
 q : parameter

4 Query DSL
curl -XGET 'http://127.0.0.1:9200/megacorp/employee/_search' -d '
{
	"query":{
		"filtered":{
			"filter":{
				"range":{
					"age":{"gt":30}
				}
			}
		},
		"query":{
			"match":{
				"last_name":"Smith"
			}
		}
	}
}'



5 短语查询 和 高亮查询
curl -XGET 'http://127.0.0.1:9200/megacorp/employee/_search' -d '
{
	"query":{
		"match_phrase":{
			"last_name":"Smith"
		}
	},
	"highlight":{
		"fields"{
			"about":{}
		}
	}
}'





6 分析和 aggregations(聚合,类似于group by)

curl -XGET 'http://127.0.0.1:9200/megacorp/employee/_search' -d '
{
	"query":{
		"match":{
			"about":"rock climbing"
		}
	},
	"aggs":{
		"all_interests":{
			"terms":{"fields":"interests"},
		}
	}
}'


curl -XGET 'http://127.0.0.1:9200/megacorp/employee/_search' -d '
{
	"aggs":{
		"all_interests":{
			"terms":{"fields":"interests"},
			"aggs":{
				"avg_age":{
					"avg":{
						"field":"age"
					}
				}
			}
		}
	}
}'






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
2019年 Manning出版, 全英文 ,下面是preface: The field of natural language processing bewitched me as soon as I came to know about it nearly 10 years ago, while studying for my master’s degree. The promise that computers could help us understand the (already, even then) vast amount of textual documents in existence sounded like magic. I still remember how exciting it was to see my first NLP programs extract even vaguely correct and useful information from a few text documents. About the same time, at work, I was asked to do some consulting for a customer on their new open source search architecture. My colleague, who was an expert in the field, was busy on another project, so I was given a copy of Lucene in Action,1 which I studied for a couple of weeks; then I was sent out on the consulting job. A couple of years after I worked on that Lucene/Solr-based project, the new search engine went live (and, as far as I know, it’s still used). I can’t tell you how many times the search engine algorithms needed to be adjusted because of this or that query or this or that fragment of indexed text, but we made it work. I could see users’ queries, and I could see the data that was there to be retrieved, but a minimal difference in spelling or omitting a certain word could cause very relevant information to not show up in the search results. So while I was very proud of my work, I kept wondering how I could have done better to avoid the many manual interventions the product managers asked me to perform in order to provide the best possible user experience. Right after this, I quite by chance found myself involved in machine learning thanks to Andrew Ng’s first machine learning online class (which originated the Coursera MOOC series). I was so fascinated with the concepts behind the neural networks shown in the class that I decided to try to implement a small library for neural networks in Java myself, just for fun (http://svn.apache.org/repos/asf/labs/yay/). I started hunting for other on

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值