码迷,mamicode.com
首页 > 其他好文 > 详细

创建索引并进行查询

时间:2017-08-07 13:45:06      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:mit   log   first   sea   url   last   als   for   john   

curl -XPUT http://localhost:9200/suoyin1



curl -XPOST http://localhost:9200/suoyin1/fulltext/_mapping -d{
    "fulltext": {
             "_all": {
            "analyzer": "ik_max_word",
            "search_analyzer": "ik_max_word",
            "term_vector": "no",
            "store": "false"
        },
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word",
                "include_in_all": "true",
                "boost": 8
            }
        }
    }
}

curl -XPOST http://localhost:9200/suoyin1/fulltext/1 -d{
    "first_name" : "John1",
    "last_name" :  "Smith1",
    "age" :        251,
    "about" :      "I love to go rock climbing1",
    "interests": [ "sports", "music1" ]
}


curl -XPOST http://localhost:9200/suoyin1/fulltext/2 -d{
    "first_name" :  "Jane1",
    "last_name" :   "Smith1",
    "age" :         321,
    "about" :       "I like to collect rock albums1",
    "interests":  [ "music1" ]
}
curl -XPOST http://localhost:9200/suoyin1/fulltext/3 -d{
    "first_name" :  "Douglas1",
    "last_name" :   "Fir1",
    "age" :         351,
    "about":        "I like to build cabinets1",
    "interests":  [ "forestry1" ]
}




curl -XPOST http://localhost:9200/suoyin/fulltext/_search  -d{
  "query": {
    "match": {
      "last_name": "smith"
    }
  }
}dsl 语句查询

http://localhost:9200/suoyin/fulltext/
{
    "query" : {
        "match" : {
            "last_name" : "Smith"
        }
    }
}

 

 

suoyin1:索引名称,相当于数据库
fulltext:文档的类型

1,2,3:员工的ID
 

 

创建索引并进行查询

标签:mit   log   first   sea   url   last   als   for   john   

原文地址:http://www.cnblogs.com/wangchuanfu/p/7298478.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!