I have a project, where I use Searchkick gem in order to fetch records from ElasticSearch first and then do further processing on them.
(我有一个项目,在这里我使用Searchkick gem,以便首先从ElasticSearch中获取记录,然后对其进行进一步处理。)
The guys that initially implemented it added a sort option by two fields in base options in SearchKick: (最初实现它的家伙在SearchKick的基本选项中通过两个字段添加了一个排序选项:)
def base options
{
fields: %i[catalogue_number oe_numbers],
match: :word_start,
misspellings: false,
where: @conditions,
load: false,
order: { sale_rotation_group: { order: :desc } }, { lauber_id_integer: { order: :desc } },
highlight: @params[:highlight]
}
end
lauber_it_integer
does not exist in the application database so it must be a field in ElasticSearch that they added.
(lauber_it_integer
在应用程序数据库中不存在,因此它必须是他们添加的ElasticSearch中的一个字段。)
Now I want to change this and instead of current order I want to tell SearchKick to tell ElasticSearch to order the records by the fields I added to the application database: images_count
and parameters_count
.
(现在,我想更改它,而不是当前顺序,我想告诉SearchKick告诉ElasticSearch通过我添加到应用程序数据库中的字段images_count
和parameters_count
来对记录进行排序。)
So probably I need to add those new fields to ElasticSearch so it knows how to order the records. (所以可能我需要将这些新字段添加到ElasticSearch中,以便它知道如何对记录进行排序。)
I changed the order option to (我将订单选项更改为)
order: { images_count: { order: :desc } }
but now I am getting the error:
(但是现在我得到了错误:)
Searchkick::InvalidQueryError ([400] {"error":{"root_cause":[{"type":"query_shard_exception","reason":"No mapping found for [images_count] in order to sort on","index_uuid":"WhC4XK8IRnmmfkPJMNmV1g","index":"parts_development_20191124205133405"}]
This will probably involve also some extra work on ElasticSearch to add data to those new fields, however I know very little about ElasticSearch.
(这可能还涉及在ElasticSearch上进行一些额外的工作,以将数据添加到这些新字段中,但是我对ElasticSearch知之甚少。)
Could you give me some indications or hints on how I could solve my problem? (您能给我一些有关如何解决问题的指示或提示吗?)
ask by jedi translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…