1. query string基础语法
1GET /test_index/test_type/_search?q=test_field:test
2GET /test_index/test_type/_search?q=+test_field:test 必须包含,其实跟上面一样
3GET /test_index/test_type/_search?q=-test_field:test 不包含
复制代码
一个是掌握q=field
:search content
的语法,还有一个是掌握+和-的含义
2. _all metadata
在搜索的时候,如果没有指定搜索的字段,就默认搜索 _all field
, 其中包含了所有 field 的值。
es中的_all元数据,在建立索引的时候,我们插入一条document,它里面包含了多个field,此时,es会自动将多个field的值,全部用字符串的方式串联起来,变成一个长的字符串,作为_all field的值,同时建立索引。
例如:
1{
2 "name": "jack",
3 "age": 26,
4 "email": "jack@sina.com",
5 "address": "guangzhou"
6}
复制代码
"jack 26 jack@sina.com guangzhou",作为这一条document的_all field的值,同时进行分词后建立对应的倒排索引.
在生产环境下不使用。
3. query string 的分词
- query string必须以和index建立时相同的analyzer进行分词
- query string对exact value和full text的区别对待