MyElasticsearch
  • Introduction
  • 基本查询
  • 简介
  • 安装
    • Window下安装
  • 基础知识
    • 理解 document
    • 简单的集群管理
    • 简单实例:简单的curd操作
    • 简单实例:批量curd操作
    • 简单实例:多种搜索方式
    • 简单实例:聚合分析
    • 附录: _index,_type,_id,_source元数据
    • 附录:手动&自动生成document id
    • 附录:全量替换、强制创建、lazy delete机制
    • 附录:search timeout机制
    • _source && _all
  • 倒排索引
  • 查询附录
    • 分页搜索
    • multi-index&multi-type搜索模式
  • 查询
    • 测试数据
    • 简单查询
    • 基本查询
      • Term,Terms,Wildcard查询
        • Term查询
        • Terms查询
      • match相关查询
      • query_string查询
      • prefix前缀查询
      • fuzzy相关查询
        • fuzzy_like_this查询
        • fuzzy_like_this_field查询
        • fuzzy查询
    • 复合查询
  • groovy脚本
    • 执行部分更新(partial update)
  • 锁机制(悲观锁、乐观锁)
    • 基于_version乐观锁并发控制
    • 基于external version乐观锁并发控制
  • 查询方式
    • Query string方式
    • Query DSL 方式
    • query filter 方式
    • 各种query搜索语法
    • 多搜索条件组合查询
    • 检验不合法的Quqery查询
    • 搜索结果的排序规则
    • field索引两次来解决字符串排序
    • 使用scoll滚动搜索
    • 分词器
  • document mapping
    • 自动mapping带来的问题
    • field类型
    • mapping中的field type类型
    • 定制化dynamic mapping策略
  • 资料
  • 原理
    • 相关度评分TF&IDF算法
    • doc values 正排索引
  • 索引的CURD
  • 附录:基于scoll+bulk+索引别名实现零停机重建索引
Powered by GitBook
On this page
  • 语法
  • 查询语句

Was this helpful?

  1. 查询

简单查询

查询Elasticsearc最简单的办法是使用URI请求查询,这种查询方法简单,但是比较局限,遵循query string查询语法,

语法

curl -XGET  'http://localhost:9200/[index_file_name1,index_file_name2..]/[type_name1,type_name2]/_search?q=field_name:keyword&pretty=true'

查询语句

  1. 查询指定索引和指定类型下的信息(指定一个index和一个type名)

    curl -XGET  'http://localhost:9200/crm/employee/_search?q=first_name:John&pretty=true'

    搜索邮箱:

    curl -XGET  'http://localhost:9200/oa/user/_search?q=email:john@smith.com&pretty=true'

    搜索子文档里的数据

    curl -XGET  'http://localhost:9200/oa/user/_search?q=sex:boy&pretty=true'

    搜索数组中的数据

    curl -XGET  'http://localhost:9200/oa/user/_search?q=interests:dolphins&pretty=true'
  2. 查询指定索引下素有类型中的信息(指定一个index,没有指定type名)

    curl -XGET  'http://localhost:9200/crm/_search?q=first_name:John&pretty=true'
  3. 查询所有索引中的信息(没有指定index和type名)

    curl -XGET  'http://localhost:9200/_search?q=first_name:John&pretty=true'
  4. 查询多个索引下所有类型中的信息(指定多个index,没有指定type名)

    curl -XGET  'http://localhost:9200/crm,oa/_search?q=interests:dolphins&pretty=true'
  5. 查询所有索引中的信息(指定多个index和多个type名)

    curl -XGET  'http://localhost:9200/crm,oa/employee,user/_search?q=interests:dolphins&pretty=true'

注意: 以上内容只是基本查询体。

Previous测试数据Next基本查询

Last updated 6 years ago

Was this helpful?