Open Jeet0027 opened 4 years ago
@mayya-sharipova, @jimczi could you please suggest
I have fixed this issue using HighlightQuery
method, but this is an alternate solution
Pinging @elastic/es-search (:Search/Highlighting)
Can you share the mapping of your fields ? We have an open issue regarding the highlighting of prefix queries when using the index_prefixes
option or search_as_you_type
.
ding the highlighting of prefix querie
Sorry for the late reply!
var indexMappingResponse = await elasticClient.Indices.CreateAsync(Settings.Index + "-text", c => c .Settings(s => s.NumberOfShards(2) .Analysis(a => a.Analyzers(an => an.Custom("rebuilt_whitespace", ca => ca.Tokenizer("whitespace") .Filters("lowercase")) ))) .Map<Document>(mp => mp .AutoMap() .Properties(ps => ps .Text(t => t .Name(n => n.Content).TermVector(TermVectorOption.WithPositionsOffsets)) .Text(t => t.Name(n => n.Tags).Analyzer("rebuilt_whitespace")) .Date(x => x.Name(n => n.date).Format("yyyy-MM-dd HH:mm:ss")) )));
Field 'Content' contains the text input
Pinging @elastic/es-search-relevance (Team:Search Relevance)
Elasticsearch version (
7.8
):OS version (
Windows 10
):Along with ScriptScore function, Highlight function does not work properly. If we search two words only first word gets higlighted or last word doesn't display highlighted:
Eg. Doc content- this is a boy On searching - this is Output content shows only 'this' as highlighted
` var searchResponse = await elasticClient.SearchAsync(body => body
) .Script(w => w.Source("String gmtString = params.searchdate;ZonedDateTime zdt = ZonedDateTime.parse(gmtString,DateTimeFormatter.RFC_1123_DATE_TIME);ZonedDateTime zdt2 =ZonedDateTime.of(doc['date'].value.year,doc['date'].value.monthOfYear,doc['date'].value.dayOfMonth,doc['date'].value.hourOfDay,doc['date'].value.minuteOfHour,doc['date'].value.secondOfMinute, 0, ZoneId.of('Z')); if (zdt2.toInstant().toEpochMilli()==zdt.toInstant().toEpochMilli()){return 100;}else{return _score;} ").Params(par)))
`
Please suggest any solution