美文网首页
爬虫及ES查询分析器搜索指令

爬虫及ES查询分析器搜索指令

作者: 木木_bfe8 | 来源:发表于2018-08-11 18:10 被阅读0次

用户代理模块
https://github.com/hellysmile/fake-useragent
http代理 西刺代理

http://www.xicidaili.com/

elasticsearch-dsl-py

可以借助接口帮我们分词
GET _analyze
{
"analyzer": "ik_smart",
"text": "python工程师"
}
es搜索
jobbole:index
article:type
1、match 会对输入的查询进行分词
GET jobbole/article/_search
{
"query" : {
"match " : { "content" : "27" }
}
}
2、term 不会对输入查询进行分词,进行全量匹配,但可以传递数据进行匹配
GET jobbole/article/_search
{
"query" : {
//"term" : { "content" : "27" }
"term" : { "content" : ["27","29","30"] }
},
"from":1,
"size":3
}
3、match_all 全查,{}为空
GET jobbole/article/_search
{
"query" : {
"match_all" : {}
}
}
3、match_phrase 会将查询先分词,查询结果包含全部分词才行,slop标示分词之间的距离,小于就不行
GET jobbole/article/_search
{
"query" : {
"match_phrase" : {
"content": {
"query": "python视频",
"slop":3
}}
}
}
4、multi_match 多个字段中,匹配查询条件
GET jobbole/article/_search
{
"query" : {
"multi_match" : {
"query": "python",
"fields": ["content","url"]
}
}
}
5、返回指定字段,前提是mapping中该字段的 store属性为true
GET jobbole/article/_search
{
"query" : {
"match" : {
"content": "python"
}
},
"stored_fields": ["content"]
}
6、还有sort之类的就不列了,看文档去
7、通配符查询
GET jobbole/article/_search
{
"query" : {
"wildcard" : {
"content": {"value": "pyth*n","boost": 2}
}
}
}
8、组合查询 bool查询
GET jobbole/article/_search
{
"query" : {
"bool": {
"must": [
{"match": {
"FIELD": "TEXT"
}}
],
"filter": {"term": {
"FIELD": "VALUE"
}},
"must_not": [
{}
],
"should": [
{}
]
}
}
}
9、高量查询 默认 高亮词会用<em>和</em>包围,你可以通过pre_tags 和 post_tags修改它:
GET jobbole/article/_search
{
"query" : {
"match": { "content": "小姐姐" }
},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {"type" : "plain"}
}
}
}

10、联想词(Suggesters)
POST jobbole/article/_search
{
"query" : {
"match": {
"content": "。。。"
}
},
"suggest" : {
"my-suggestion" : {
"text" : "",
"term" : {
"field" : "content"
}
}
}
}

相关文章

  • 爬虫及ES查询分析器搜索指令

    用户代理模块https://github.com/hellysmile/fake-useragenthttp代理 ...

  • ES7学习笔记(七)IK中文分词器

    在上一节中,我们给大家介绍了ES的分析器,我相信大家对ES的全文搜索已经有了深刻的印象。分析器包含3个部分:字符过...

  • MongoDB优化

    备注:MongoDB 4.2 版本 一.查询分析器 1.1 启用查询分析器 1.2 禁用查询分析器 1.3 记录慢...

  • ES 学习 (分组,区间,排序,分页,高亮)

    ES 搜索 1 分组查询 类比mysql数据库 ES中 (使用elasticsearchTemplate) 规格分...

  • ES 全文搜索

    ES 全文搜索 全文搜索 使用了match查询的多词查询只是简单地将生成的term查询包含在了一个bool查询中。...

  • Elasticsearch基础概念之查询流程

    ES查询流程 查询流程总体可以分为以下几个部分 请求解析 搜索Query阶段 搜索Fetch阶段 数据排序和合并 ...

  • 16.ES的查询

    查询 ES是功能非常强大的搜索引擎,使用它的目的就是为了快速的查询到需要的数据查询分类:基本查询:使用ES内置的查...

  • Linux常见命令

    1、快速查询历史输入指令 ctrl+r,再输入搜索字符查找便可。 2、find 指令和grep指令 用法:...

  • 自定义分词器

    前言 es能够实现快速的全文搜索,除了依赖其本身倒排索引的思想,还依赖其分词器 分析器 es本身内置了一些常用的分...

  • ES查询相关

    ES查询相关 查询所有数据、搜索所有数据 或者 term与terms 查询name="python"的所有数据 t...

网友评论

      本文标题:爬虫及ES查询分析器搜索指令

      本文链接:https://www.haomeiwen.com/subject/idtdbftx.html