ElasticSearch (3) – URL查询
1. 泛查询,针对全部字段进行搜索
GET people/_search?q=kiat2
{
"profile":"true"
}

2. 针对指定字段进行查询
GET people/_search?q=kiat2
{
"profile":"true"
}
3. Term查询, 查询字:kiat or fatty
GET people/_search?q=name:kiat fatty
{
"profile":"true"
}
4. Phrase查询, 查询字:kiat and fatty
GET people/_search?q=name:"kiat fatty"
{
"profile":"true"
}
GET people/_search?q=name:(kiat AND fatty)
{
"profile":"true"
}
5. 范围查询
搜寻10岁至1000岁
GET people/_search?q=age:[10 TO 1000]
{
"profile":"true"
}
搜寻10岁至无限
GET people/_search?q=age:[10 TO *]
{
"profile":"true"
}
6. 数符号查询, 找出大于100岁
GET people/_search?q=age:>100
{
"profile":"true"
}
7. 布尔操作 AND / OR / NOT 或者 && / || / !
找出kiat不fatty的字眼
GET people/_search?q=name:(kiat NOT fatty)
{
"profile":"true"
}
8. 通配付查询 ( ?代表一个字符,*代表0或多个字符)
注意:查询效率低,内存占用大,不建议使用
找出ki开头的关键字
GET people/_search?q=name:ki*
{
"profile":"true"
}
找出ki开头,t结尾的相关字
GET people/_search?q=name:ki?t
{
"profile":"true"
}
9. 模糊匹配 , 大概找出beautiful的字眼,虽然拼音错误了
GET people/_search?q=name:beautifl~1
{
"profile":"true"
}
10. 近似度匹配 , 大概找到 Lord of the Rings 关键字
GET people/_search?q=name:"Lord Rings"~2
{
"profile":"true"
}
![]()
Facebook评论