首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用AND运算符的基于Elasticsearch URI的查询

使用AND运算符的基于Elasticsearch URI的查询
EN

Stack Overflow用户
提问于 2012-12-05 13:12:37
回答 4查看 55K关注 0票数 30

如何在基于URI的查询中指定AND操作?我正在寻找类似这样的东西:

代码语言:javascript
复制
http://localhost:9200/_search?q="profiletype:student AND username:s*"
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2012-12-05 14:00:42

根据文档,它应该按照您所描述的那样工作。请参阅http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html

也就是说,您还可以使用以下内容:

代码语言:javascript
复制
http://localhost:9200/_search?q="+profiletype:student +username:s*"
票数 26
EN

Stack Overflow用户

发布于 2014-01-10 18:12:43

对于ElasticSearch中的URI search,您可以使用AND运算符profiletype:student AND username:s,正如您所说的,但不带引号:

代码语言:javascript
复制
  _search?q=profiletype:student AND username:s*

还可以将缺省运算符设置为AND

代码语言:javascript
复制
  _search?q=profiletype:student username:s*&default_operator=AND

或者,您可以对必须存在的术语使用+ operator,即使用+profiletype:student +username:s作为查询字符串。但是,如果没有URL编码,这是不起作用的。在URL编码中,+%2B,空格是%20,因此另一种方法是

代码语言:javascript
复制
  _search?q=%2Bprofiletype:student%20%2Busername:s*
票数 25
EN

Stack Overflow用户

发布于 2017-06-14 04:00:02

你可以试试下面的线路。

代码语言:javascript
复制
http://localhost:9200/_search?q=profiletype:student%20AND%20username:s*

http://localhost:9200/_search?q=profiletype:student AND username:s*
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13716719

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档