GreenFaith / GreenFaith.github.io

wiki.shixiz.com
1 stars 0 forks source link

elasticSearch #16

Open GreenFaith opened 10 years ago

GreenFaith commented 10 years ago

Schema mapping

ES 即便不定义 mapping 也能工作(使用默认)
mapping 可以为 document 定义 Schema (废话),字段是否被索引,是否存储,
选择合适的分词插件等。这些定义将决定整个搜索的各种表现。

boost 字段的匹配得分将乘以这个系数

GreenFaith commented 10 years ago

默认==>定制

GreenFaith commented 10 years ago

状态观察

elasticSearch 有插件可以实现 web 监控页面。 对于不想装插件的,使用如下 api:

curl 'localhost:9200/_cat/indices?bytes=mb'
GreenFaith commented 10 years ago

分析器

加上中文分词器后索引慢出翔。(使用 ik 分词)

测试分词效果

localhost:9200/index/_analyze?analyzer=ik&pretty=true&text=中文分词(Chinese Word Segmentation) 指的是将一个汉字序列切分成一个一个单独的词.分词就是将连续的字序列按照一定的规范重新组合成词序列的过程。
GreenFaith commented 10 years ago

搜索

普遍适用的真理是:

        "query" : { 
  5             "multi_match" : 
  6                     { 
  7                         "query":"中国魔都" ,
  8                         "fields":["title","content"]
  9                     }
 10     }

这个会自动对中国魔都分词,得到中国魔都两个词 然后在 fields 指定的字段以 OR 的逻辑搜索各个字段 对于普通的搜索,这个很好使用。

GreenFaith commented 10 years ago

不停服务,重建索引

使用 alias 来访问 index http://donlianli.iteye.com/blog/1924721

dbbbit commented 10 years ago

Tag 索引

将分词完整的索引简化成 Tag 索引。没有命中 Tag 的不进入索引。