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

Highlight fields in request order #6178

Closed
wants to merge 1 commit into from

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented May 14, 2014

Because json objects are unordered this also adds an explicit order syntax
that looks like

    "highlight": {
        "fields": [
            {"title":{ /*params*/ }},
            {"text":{ /*params*/ }}
        ]
    }

This is not useful for any of the builtin highlighters but will be useful
in plugins.

Closes #4649

@nik9000
Copy link
Member Author

nik9000 commented May 14, 2014

This doesn't actually implement conditional highlighting but it gives plugins the one tool that they need to implement it themselves: guaranteed execution order. Without it the fields are highlighted in hashmap iteration order which means the plugin can't push data from one field to the next reliably.

* Use a syntax that is explicit about the order in which fields should be highlighted.
* @return this for chaining
*/
public SearchRequestBuilder setHighlighterExplicitFieldOrderSyntax(boolean explicitFieldOrderSyntax) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe just setHighlighterExplicitFieldOrder?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, adding syntax is a bit pedantic, right? I'll change it. As a side note, even without the explicit field order syntax they'll still be executed in the order that they appear in the document. It just didn't feel with it to randomize the order if the syntax wasn't used.

@jpountz
Copy link
Contributor

jpountz commented May 22, 2014

@nik9000 I left a minor comment about the name of the parameter that allows to make the field order explicit but other than that this looks good to me!

@nik9000
Copy link
Member Author

nik9000 commented May 22, 2014

Done!

@nik9000
Copy link
Member Author

nik9000 commented May 22, 2014

Sorry, not quite done. On more moment.

Because json objects are unordered this also adds an explicit order syntax
that looks like
    "highlight": {
        "fields": [
            {"title":{ /*params*/ }},
            {"text":{ /*params*/ }}
        ]
    }

This is not useful for any of the builtin highlighters but will be useful
in plugins.

Closes elastic#4649
@nik9000
Copy link
Member Author

nik9000 commented May 22, 2014

Done.

@jpountz
Copy link
Contributor

jpountz commented May 22, 2014

Merged. Thanks, Nik!

@jpountz jpountz closed this May 22, 2014
@jpountz jpountz changed the title Highlight fields in request order Highlighting: highlight fields in request order May 30, 2014
@clintongormley clintongormley changed the title Highlighting: highlight fields in request order Highlighting: Highlight fields in request order Jul 16, 2014
@clintongormley clintongormley changed the title Highlighting: Highlight fields in request order Highlight fields in request order Jun 7, 2015
@clintongormley clintongormley added the :Search/Highlighting How a query matched a document label Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conditional highlighting
3 participants