• 分布式搜索elasticsearch 文献检索索引 入门


    1、首先,例如,下面的数据被提交给ES该指数

    {"number":32768,"singer":"杨坤","size":"5109132","song":"今夜二十岁","tag":"中国好声音","timelen":319}
    {"number":32769,"singer":"汪峰","size":"6001697","song":"我爱你中国","tag":"中国好声音","timelen":375}
    {"number":32780,"singer":"汪峰","size":"4070469","song":"我如此爱你","tag":"中国好声音","timelen":254}
    {"number":32796,"singer":"大小姐","size":"3046005","song":"登大人","tag":"儿歌","timelen":190}
    {"number":32896,"singer":"Bandari","size":"3869593","song":"The Golden Land","tag":"胎教音乐","timelen":241}
    {"number":32977,"singer":"Bandari","size":"3477514","song":"Childhood Memory","tag":"欧美","timelen":217}

    2、ElasticSearch's query DSL

    搜索的RESTful接口是_search

    URL形式:http://ip:port/index/type/_search

    query查询语句通过POST的方式发送到ES。

    a、主要的全文检索

    查找索引库中包括"音乐"的记录

    {
      "query": {
        "query_string": {
          "query": "音乐"
        }
      }
    }


    b、指定字段进行检索

    查找song字段中含有中国的记录

    {
      "query": {
        "query_string": {
          "query": "中国",
          "fields": [
            "song"
          ]
        }
      }
    }


    c、多字段权重查询

    在song、tag两个字段中搜索keyword“中国”,假设在song字段中出现权重是2。tag中是默认的1。

    通过结果能够看到歌曲名中含有中国是排在前面。

    {
      "query": {
        "multi_match": {
          "query": "中国",
          "fields": [
            "song^2",
            "tag"
          ]
        }
      }
    }


    很多其它具体的查询语法能够參考:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-queries.html

    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    Git查询
    HDU-3038 How Many Answers Are Wrong 并查集
    CodeForcesEducationalRound40-D Fight Against Traffic 最短路
    HDU-6109 数据分割 并查集(维护根节点)
    ZOJ-3261 Connections in Galaxy War 并查集 离线操作
    AtCoderBeginner091-C 2D Plane 2N Points 模拟问题
    HDU-1878 欧拉回路 欧拉回路
    [笔记-图论]Floyd
    [笔记-图论]Bellman-Ford
    [笔记-图论]Dijkstra
  • 原文地址:https://www.cnblogs.com/yxwkf/p/4628518.html
Copyright © 2020-2023  润新知