我正在使用ReactiveSearch构建一个React JS网站,以从Elastic Search(AWS)检索数据。
我正在尝试为我的弹性搜索索引中的嵌套字段提供搜索和突出显示。 我听说 inner_hits 是在嵌套元素中启用突出显示的一种方法。
我正在使用 cell.SelectedBackgroundView = new UIView
{
BackgroundColor = view.SelectedBackgroundColor.ToUIColor()
};
return cell;
}
组件的customQuery
道具来提供以下DSL查询。
DataSearch
我要搜索的数据字段是 col_attr.rs_column_description , col_attr.user_column_description 和 col_attr.column_name 。
请注意<DataSearch
componentId="myCustomShit"
dataField="col_attr.completion_column_name"
title="Column Name"
highlight={false}
placeholder="Enter Column Name"
URLParams
customQuery={(value, props) => {
// if the search is blank then do nothing
if (!value) return {};
//else return a custom
return {
size: 15,
from: "0",
highlight: {
pre_tags: ["<mark>"],
post_tags: ["</mark>"],
order: "score",
fields: {
table_name: {},
rs_table_description: {},
user_table_description: {}
}
},
query: {
bool: {
should: [
{
multi_match: {
query: value,
fields: [
"table_name^2",
"user_table_description",
"rs_table_description"
]
}
},
{
nested: {
path: "col_attr",
inner_hits: {
size: 10,
_source: true,
highlight: {
pre_tags: ["<mark>"],
post_tags: ["</mark>"],
tags_schema: "styled",
fragmenter: "span",
fragment_size: 60,
number_of_fragments: 2,
order: "score",
fields: {
"col_attr.column_name": {},
"col_attr.rs_column_description": {},
"col_attr.user_column_description": {}
}
}
},
query: {
bool: {
should: [
{
match: {
"col_attr.column_name": value
}
},
{
match: {
"col_attr.user_column_description": value
}
},
{
match: {
"col_attr.rs_column_description": value
}
}
]
}
}
}
}
]
}
}
};
}}
/>
是一个对象数组,在每个对象中, rs_column_description , user_column_description 和 column_name 找到。
虽然搜索似乎按预期工作正常,但我注意到嵌套字段的突出显示结果位于名为col_attr
的单独对象中,该对象不会进行反应性搜索或返回。
ReactiveList提供对inner_hits
参数的访问,该参数本质上是从es返回的data
对象。
我可以访问hits
吗?是否有其他方法可以在反应式搜索中获取嵌套元素的突出显示?