dsgdg54ef4365 2017-08-23 12:40 采纳率: 0%
浏览 196

如何使用Elasticsearch PHP SDK设置search_type

I would like to set the search_type with the PHP SDK of Elasticsearch.

At the moment my params looks like this:

$params = [
  "from" => 0
  "size" => 20
  "_source" => [...]
  "body" => [
    "query" => [
      "bool" => [
        "must" => [
          "multi_match" => [
            "query" => "searchTerm"
            "fields" => [...]
            "operator" => "and"
            "type" => "cross_fields"
          ]
        ]
      ]
    ]
  ]
];

According to this issue https://github.com/elastic/elasticsearch-php/issues/121 I simply have to add the search_type to $params

$params['search_type'] = 'dfs_query_then_fetch';

Also I tried to add it to the body

$params['body']['search_type'] = 'dfs_query_then_fetch';

Both options are invalid and return a BadRequest400Exception.

According to the repository, it is possible to add the parameter. https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/Client.php#L915

Here it says enum as data type. What exactly is enum in PHP? And what is it in this particular situation?

Does anyone have an example for me, how to add the search_type correct?

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • 流水彷徨& 2022-05-17 09:47
    关注

    瞎搞

    评论

报告相同问题?

悬赏问题

  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条