My apologies in advance as I'm new to ES. This is kind of a strange use-case, but we have a large text field that we would like to do 2 things with:
Show the first X chars of the body text with any search results highlighted
Show the first Y highlights/fragments of the body text with search results highlighted
My goal is to do this all in one search, but I can't find a way to get the same field back with different highlighting parameters. I was thinking maybe if I had some way to create an alias on the field then I could refer to it in the highlights section but I couldn't find a way to do that either.
We can simply store the first X chars of the document as a separate field to work around the issue, but the developer handing ingestion would prefer to avoid that.
Right. So if you were willing to hack on highlighting you could implement this but Elasticsearch doesn't have a feature like that. It has "return the first x characters if nothing in this field matched" (no_match_size) and it has "return the x best fragments" (that is highlighting's default).
You'd make one field but analyze it twice, once limiting the token count to 1000 or something suitably small and the other time without the limit. Then you'd highlight against both of the names. Note: this'd get you the first 1000 words not the first 1000 characters. But words are better than characters any way!
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.