gpt4 book ai didi

php - Lucene样式查询字符串Elasticsearch PHP

转载 作者:行者123 更新时间:2023-12-03 00:27:16 24 4
gpt4 key购买 nike

我已经搜索了几天如何使用数组作为参数或使用JSON格式从Elasticsearch查询数据,如此页面上所示http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_quickstart.html
但不能使用Lucene样式的查询字符串。有什么方法可以通过Elasticsearch PHP Client API使用Lucene样式的查询字符串从Elasticsearch查询数据,例如(type:apache-access或type:apache-error)?

最佳答案

我相信您可以通过uri通过Elasticsearch基本查询来执行此操作:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-uri-request.html

curl -XGET 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy'

在此处进行一些讨论(包括它支持Lucene样式查询的事实):

http://okfnlabs.org/blog/2013/07/01/elasticsearch-query-tutorial.html

Querying Basic Queries Using Only the Query String

Basic queries can be done using only query string parameters in the URL. For example, the following searches for text ‘hello’ in any field in any document and returns at most 5 results:


{endpoint}/_search?q=hello&size=5

Basic queries like this have the advantage that they only involve accessing a URL and thus, for example, can be performed just using any web browser. However, this method is limited and does not give you access to most of the more powerful query features.

Basic queries use the q query string parameter which supports the Lucene query parser syntax and hence filters on specific fields (e.g. fieldname:value), wildcards (e.g. abc*) and more.

There are a variety of other options (e.g. size, from etc) that you can also specify to customize the query and its results. Full details can be found in the ElasticSearch URI request docs.

关于php - Lucene样式查询字符串Elasticsearch PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23612130/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com