首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ingest搜索(弹性搜索)不适用于PHP

Ingest搜索(弹性搜索)不适用于PHP
EN

Stack Overflow用户
提问于 2017-01-22 16:28:59
回答 1查看 198关注 0票数 4

我已经安装了弹性搜索,也安装在我的本地服务器上的插件。弹性发动机运转良好。我设置了以下任务:

  1. 映射
  2. 标引

现在我被困在寻找,它不起作用。它返回空数组。下面是我在PHP中的代码:

代码语言:javascript
复制
public function ingest_processor_searching($query)
{
    $client = $this->client;
    $params = [
        'index' => 'ingest_index',
        'type' => 'attachment',
        'body' => [
            'query' => [
                'match' => [
                    'textField' => $query,
                ]
            ],
        ],
    ];

    $response = $client->search($params);
    return $response;
}

结果:

代码语言:javascript
复制
{
"took": 7,
"timed_out": false,
"_shards": {
   "total": 5,
   "successful": 5,
   "failed": 0
 },
  "hits": {
  "total": 0,
  "max_score": null,
  "hits": []
 } 
}

但是我有GET http://localhost:9200/ingest_index/attachment/2的数据

代码语言:javascript
复制
{
  "_index": "ingest_index",
  "_type": "attachment",
  "_id": "2",
  "_version": 1,
  "found": true,
  "_source": {
    "file_path": "/Users/selimreza/Sites/haber_dev/public/uploads/files/bower.txt",
    "attachment": {
      "content_type": "text/plain; charset=ISO-8859-1",
      "language": "en",
      "content": "Welcome to Dhaka",
      "content_length": 18
    },
    "textField": "V2VsY29tZSB0byBEaGFrYQo="
  }
}

我犯了什么错?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-23 08:46:18

尝试从您的,中删除'textField' => $query,因为您不匹配多个值。如果仍然不能工作,请尝试使用术语查询而不是match

代码语言:javascript
复制
 $params = [
        'index' => 'ingest_index',
        'type' => 'attachment',
        'body' => [
            'query' => [
                'term' => [ <-- have this
                    'textField' => $query <-- try removing the comma
                ]
            ],
        ],
    ];
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41793344

复制
相关文章

相似问题

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