主要知识点:

1、queery string 分词

2、38节中搜索结果解析

3,测试分词器

 
 

query string分词

query string必须以和index建立时相同的analyzer进行分词

query string对exact value和full text的区别对待

比如我们有一个document,其中有一个field,包含的value是:hello you and me,建立倒排索引。

我们要搜索这个document对应的index,搜索文本是hell me,这个搜索文本就是query string,默认情况下,es会使用它对应的field建立倒排索引时相同的分词器去进行分词和normalization,只有这样,才能实现正确的搜索。

比如,我们建立倒排索引的时候,将dogs --> dog,结果你搜索的时候,还是一个dogs,那不就搜索不到了吗?所以搜索的时候,那个dogs也必须变成dog才行。才能搜索到,所以必须是相同的分词器。不同类型的field,可能有的就是full text,有的就是exact value。

 
 

二、38小节中对搜索结果的讲解

  • GET /website/article/_search?q=2017                         3条结果
  • GET /website/article/_search?q=2017-01-01          3条结果
  • GET /website/article/_search?q=post_date:2017-01-01         1条结果
  • GET /website/article/_search?q=post_date:2017         1条结果

 
 

1、GET /_search?q=2017

搜索的是_all field,document所有的field都会拼接成一个大串,进行分词,其中2017-01-02会进行分词成2017、01、02,所以用_all 搜索2017时能把三个docuemnt都搜索出来。

 
 

2、GET /_search?q=2017-01-01

同样道理,query string会用跟建立倒排索引一样的分词器去进行分词(会把2017-01-01 分成2017、01),再进行搜索时,3个文档都有2017,所以会是三个结果。

 
 

3、GET /_search?q=post_date:2017-01-01

 
 

搜索特定的field,post_date,会作为exact value去建立索引,2017-01-01没有被分词,只有doc1中才有2017-01-01,所以只有一个结果

 
 

4、GET /_search?q=post_date:2017

这是es 5.2以后所做的一个优化,具体原理以后会学到。

 
 

三、测试分词器

 
 

GET /_analyze

{

"analyzer": "standard",

"text": "Text to analyze"

}

执行结果是:

{

"tokens": [

{

"token": "text",

"start_offset": 0,

"end_offset": 4,

"type": "<ALPHANUM>",

"position": 0

},

{

"token": "to",

"start_offset": 5,

"end_offset": 7,

"type": "<ALPHANUM>",

"position": 1

},

{

"token": "analyze",

"start_offset": 8,

"end_offset": 15,

"type": "<ALPHANUM>",

"position": 2

}

]

}

 
 

 
 

42.query string分词的更多相关文章

  1. 37.query string、_all metadata

    主要知识点 1.query string基础语法 2._all metadata的理解     一.query string基础语法 1.GET /test_index/test_type/_sear ...

  2. Elasticsearch由浅入深(七)搜索引擎:_search含义、_multi-index搜索模式、分页搜索以及深分页性能问题、query string search语法以及_all metadata原理

    _search含义 _search查询返回结果数据含义分析 GET _search { , "timed_out": false, "_shards": { , ...

  3. How to get the query string by javascript?

    http://techfunda.com/Tools/XmlToJson http://beautifytools.com/xml-to-json-converter.php https://www. ...

  4. nodejs笔记三--url处理、Query String;

    URL--该模块包含用以 URL 解析的实用函数. 使用 require('url') 来调用该模块. 一.parse函数的基础用法 parse函数的作用是解析url,返回一个json格式的数组,请看 ...

  5. <原>ASP.NET 学习笔记之HTML helper中参数何时会是路由参数,何时又会是query string?

    HTML helper中参数何时会是路由参数,何时又会是query string?   @Html.ActionLink("Edit", "Edit", new ...

  6. query string parameters 、 Form Data 、 Request Payload

    微信小程序ajax向后台传递参数的时候总是报400错误 然后看了一下network 发现是query string parameters,但是我写的header如下 header:{ "Co ...

  7. springMVC接收参数的区别form data与query string parameters与request payload

    在AJAX请求中,我见过有三种form表单数据类型提交. 第一种:form data, 第二种:query string parameters,第三种:request payload. 在google ...

  8. http 请求参数之Query String Parameters、Form Data、Request Payload

    Query String Parameters 当发起一次GET请求时,参数会以url string的形式进行传递.即?后的字符串则为其请求参数,并以&作为分隔符. 如下http请求报文头: ...

  9. asp.net query string 及 form data 遇到的编码问题

    当遇到此问题时,脑海里闪过的第一个解决方案是设置 web.config 的编码.但一想,就某一个页面的需求而导致其他跟着妥协,不是好的解决方案.于是网上搜索答案,下面做个小分享,遗憾的是研究不够深入, ...

随机推荐

  1. 数据结构(C实现)------- 顺序栈

    栈是限定仅在表的一端进行插入或删除的纯属表,通常称同意插入.删除的一端为栈顶(Top),对应在的.则称还有一端为栈底(Bottom). 不含元素的栈则称为空栈. 所设栈S={a1,a2,a3,..., ...

  2. SecureCRT——设置打印中文字符

    1. 设置方法 使用SecureCRT打印由STM32发送的中文字符提示信息,显示乱码.在网上找了一些链接,再加上自己摸索,终于出了能够让SecureCRT打印中文的方法. 设置以下几个地方即可. 1 ...

  3. category中添加属性的简单方式

    一.概念扩充: 1.如我们所知,使用category是用来对现有类进行功能扩展,或者将类分成多模块的一种方式.由声明和实现两部分组成.可以单独写成Objiective-C File类型文件(包含.h和 ...

  4. preg_match_all匹配网络上文件

    <?php$ssa=file_get_contents("http://www.oschina.net/code/snippet_4873_5256");preg_match ...

  5. HDU3533 Escape

    题目: The students of the HEU are maneuvering for their military training. The red army and the blue a ...

  6. A - Infinite Sequence

    Problem description Consider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2,  ...

  7. HTML <!DOCTYPE>标签

    一般一个基本html页面的结构,如下代码所示: <html> <head> <title>我是基本的页面结构</title> </head> ...

  8. input表单(02)

    01.表单的代码实现 <!DOCTYPE html> <html> <head> <title>世纪佳缘,你在我也在</title> < ...

  9. 安卓学习之学生签到APP(一)

    一.学生定位签到页面 具体实现步骤: 1.1 高德地图申请key 1.创建新应用 进入高德地图api控制台,创建一个新应用.如果您之前已经创建过应用,可直接跳过这个步骤. 2.添加新Key 在创建的应 ...

  10. dubbo之直连提供者

    在开发及测试环境下,经常需要绕过注册中心,只测试指定服务提供者,这时候可能需要点对点直连,点对点直联方式,将以服务接口为单位,忽略注册中心的提供者列表,A 接口配置点对点,不影响 B 接口从注册中心获 ...