Closed
Description
Elasticsearch Version
8.2.2
Installed Plugins
nori, kuromoji
Java Version
17.0.2
OS Version
centos 7.9
Problem Description
MapperService mapperService = createMapperService("""
{ "_doc" : { "properties" : {
"field" : {
"type" : "text",
"fields" : {
"stemmed" : {
"type" : "text",
"term_vector" : "with_positions_offsets"
}
}
}
}}}
""");
ParsedDocument doc = mapperService.documentMapper().parse(source("""
{ "field" : "here is some text, which is followed by some more text" }
"""));
{
// test SimpleFragmentsBuilder case
SearchSourceBuilder search = new SearchSourceBuilder().query(QueryBuilders.termQuery("field.stemmed", "some"))
.highlighter(new HighlightBuilder().field("field.stemmed").highlighterType("fvh"));
assertHighlights(
highlight(mapperService, doc, search),
"field.stemmed",
"here is <em>some</em> text, which is followed by <em>some</em> more text"
);
}
When the test is performed in the same way as the test case in the file above, the highlight field is not exposed in the search results.
The highlight for field
is exposed, but the highlight for `field.stemmed" is not.
One interesting thing is that if I select "type" other than "fvh", it works fine.
Steps to Reproduce
- create index
request :
PUT test_index
{
"settings": {},
"mappings": {
"properties": {
"field" : {
"type" : "text",
"term_vector" : "with_positions_offsets",
"analyzer": "english",
"fields" : {
"stemmed" : {
"type": "text",
"term_vector" : "with_positions_offsets",
"analyzer": "english"
}
}
}
}
}
}
- insert data
request :
POST test_index/_doc/1?timeout=5m
{
"field": "one"
}
- search with highlight
GET test_index/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"field.stemmed": "one"
}
},
{
"match": {
"field": "one"
}
}
]
}
},
"highlight": {
"fields":{
"*": {
"type": "fvh"
}
}
}
}
response :
{
"took" : 726,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 0.36464313,
"hits" : [
{
"_index" : "test_index",
"_id" : "1",
"_score" : 0.36464313,
"_source" : {
"field" : "one"
},
"highlight" : {
"field" : [
"<em>one</em>"
]
}
}
]
}
}
Where is my field.stemmed
in highlight? T_T
Logs (if relevant)
No response