Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlighting returning an excerpt even with no highlights #1171

Closed
ofavre opened this Issue Jul 27, 2011 · 5 comments

Comments

Projects
None yet
4 participants
@ofavre
Copy link
Contributor

commented Jul 27, 2011

Highlighting is great as providing an highlighted excerpt, but if you run no query against one field, you will have no output at all.
Highlighting could provide a non highlighted excerpt (some number of characters from the beginning of the value) as a fallback.
This would be yield shorted answers than always asking for the whole field content (that may be quite long).

{
  "highlight" : {
    "fields" : {
      "text" : {
        "number_of_fragments" : 3,
        "size_of_fragments" : 150,
        "no_results" : VALUE
      }
    }
  }
}

Where VALUE could take: hide (default), show, or a character count.
Where show would be equivalent to setting the character count to number_of_fragments * size_of_fragments.

@ppearcy

This comment has been minimized.

Copy link
Contributor

commented Mar 13, 2012

While not ideal, a temp workaround is to use a script field to always grab a chunk of text and choose between that one if highlights don't come back. Something like this:

"script_fields":
{"data.fragment":
{"script":"if (_source[fieldName] == null || _source[fieldName].length() < fragmentSize) return _source[fieldName];\nreturn _source[fieldName].substring(0, fragmentSize);",
"params":{"fragmentSize":300,"fieldName":"data"}
}
}

@nik9000

This comment has been minimized.

Copy link
Contributor

commented Sep 3, 2013

I opened and then just closed 3609 which is a dupe of this issue. This issue is better written any way.

The script isn't really a great workaround for me because it doesn't respect boundary_chars and boundary_max_scan.

@javanna

This comment has been minimized.

Copy link
Member

commented Sep 3, 2013

@nik9000 Are you familiar with highlighting? Would you like to send a pull request for this?

@nik9000

This comment has been minimized.

Copy link
Contributor

commented Sep 3, 2013

The only thing in ES I think I come close to understanding is phrase suggestions. I'll see if I can figure it out though.

@nik9000

This comment has been minimized.

Copy link
Contributor

commented Sep 3, 2013

That last commit should work for this. I'd love for someone to point out a better way to do this for the plain highlighter - currently that one works pretty much just like the script above. The FVH though does all its normal FVH things including boundary_chars and boundary_max_scan. The api is literally exactly as proposed by @ofavre two years ago.

nik9000 added a commit to nik9000/elasticsearch that referenced this issue Oct 22, 2013

Highlighting can return excerpt with no highlights
You can configure the highlighting api to return an excerpt of a field
even if there wasn't a match on the field.

The FVH makes excerpts from the beginning of the string to the first
boundary character after the requested length or the boundary_max_scan,
whichever comes first.  The Plain highlighter makes excerpts from the
beginning of the string to the end of the last token before the requested
length.

Closes elastic#1171

@javanna javanna closed this in 14a709f Oct 24, 2013

javanna added a commit that referenced this issue Oct 24, 2013

Minor changes to no_match_size highlight parameter and highlight tests (
#1171)

- Randomly store the field to highlight
- Updated test to use common assertions
- Restored previously commented out testCommonTermsQuery

javanna added a commit that referenced this issue Oct 24, 2013

Highlighting can return excerpt with no highlights
You can configure the highlighting api to return an excerpt of a field
even if there wasn't a match on the field.

The FVH makes excerpts from the beginning of the string to the first
boundary character after the requested length or the boundary_max_scan,
whichever comes first.  The Plain highlighter makes excerpts from the
beginning of the string to the end of the last token before the requested
length.

Closes #1171

javanna added a commit that referenced this issue Oct 24, 2013

Minor changes to no_match_size highlight parameter and highlight tests (
#1171)

- Randomly store the field to highlight
- Updated test to use common assertions
- Restored previously commented out testCommonTermsQuery

maxcom added a commit to maxcom/lorsource that referenced this issue Nov 5, 2013

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Highlighting can return excerpt with no highlights
You can configure the highlighting api to return an excerpt of a field
even if there wasn't a match on the field.

The FVH makes excerpts from the beginning of the string to the first
boundary character after the requested length or the boundary_max_scan,
whichever comes first.  The Plain highlighter makes excerpts from the
beginning of the string to the end of the last token before the requested
length.

Closes elastic#1171

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Minor changes to no_match_size highlight parameter and highlight tests (
elastic#1171)

- Randomly store the field to highlight
- Updated test to use common assertions
- Restored previously commented out testCommonTermsQuery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.