dongmian8108 2019-06-05 17:56
浏览 210

在使用带有elasticsearch的scount时,如何在laravel搜索中对同一索引的类型进行排序和组合?

I have a Laravel application. I installed elasticsearch server and implemented it to laravel using scout and tamayo/laravel-scout-elastic.

All is working almost perfectly. I have two questions that I can't find the answer to.

  1. How to order the output of the results by most words matching. Or _score of the elastic results

  2. How to combine two types of the same index? I have index by the name of news how to combine world news and sports news?

I am using this method to make the search:

$searched = Model::search($q)->get();

In the model I've included the Scout

use Laravel\Scout\Searchable; and use Searchable;

  • 写回答

1条回答 默认 最新

  • doutu3352 2019-06-07 14:03
    关注
    1. You can pass callback to search method and customize request https://laravel.com/docs/master/scout#customizing-engine-searches

    2. There is no way to do it with tamayo/laravel-scout-elastic but you can do it with https://github.com/matchish/laravel-scout-elasticsearch if you ready to move types in separated indices. In Elasticsearch 7 mapping types have been removed so I recommend do it anyway.

    评论

报告相同问题?

悬赏问题

  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换