https://github.com/elastic/elasticsearch
Revision 257afc4730cedff239a5fe9d56cb8eb4b426668a authored by Nik Everett on 18 April 2014, 21:01:29 UTC, committed by Nik Everett on 19 April 2014, 02:03:37 UTC
Adds a "conditional" object under each highlighting field that can contain
other fields.  Those fields are highlighted based on if there was a match
in the containing field.

It'll let you do things like this example in the docs:

This example extracts extracts the first 100 characters from `text` if there is
a match in `title`, otherwise it highlights `text` as normal.

{
    "highlight": {
        "fields": {
            "title": {
                "conditional": {
                    "match": {
                        "text": {
                            "no_match_size": 100,
                            "skip_matching":  true
                        }
                    }
                    "no_match": {
                        "text": {
                            "no_match_size": 100
                        }
                    },
                }
            }
        }
    }
}

Also adds a setting to instruct the highlighter to skip its normal match
logic and just do its no_match_size stuff.   This is very useful with
conditional highlighting "chains" that end in a no_match_size extracting
a previous entry in the chain.  Like this example from the docs:
{
    "highlight": {
        "fields": {
            "text": {
                "conditional": {
                    "no_match": {
                        "auxiliary_text": {
                            "conditional": {
                                "no_match": {
                                    "file_text": {
                                        "conditional": {
                                           "no_match": {
                                               "text": {
                                                    "no_match_size": 100,
                                                    "skip_matching": true
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Closes #4649
1 parent 12bbe28
History
Tip revision: 257afc4730cedff239a5fe9d56cb8eb4b426668a authored by Nik Everett on 18 April 2014, 21:01:29 UTC
Add support for conditional highlighting
Tip revision: 257afc4
File Mode Size
.settings
bin
config
dev-tools
docs
lib
rest-api-spec
src
.gitignore -rw-r--r-- 816 bytes
.travis.yml -rw-r--r-- 145 bytes
CONTRIBUTING.md -rw-r--r-- 6.1 KB
LICENSE.txt -rw-r--r-- 11.1 KB
NOTICE.txt -rw-r--r-- 150 bytes
README.textile -rw-r--r-- 8.2 KB
TESTING.asciidoc -rw-r--r-- 6.9 KB
core-signatures.txt -rw-r--r-- 2.6 KB
pom.xml -rw-r--r-- 65.8 KB

README.textile

back to top