Native script for matching facet values against specified query.
It's maily supposed to be used as a validation tool for facet values when suggesting facet on array field, since you might get values that match your query along with other values in that array field. It's pretty simple right now, it checks if facet term contains the query. We plan to include more advanced options with usage of Lucene query.
- Clone the repository in ElasticSearch root:
cd /usr/share/elasticsearch # or cd elasticsearch-VERSION
git clone https://github.com/otvorenesudy/elasticsearch-facet-matcher.git
cd elasticsearch-facet-matcher
- Open
Rakefile
and change required libraries verions ofelasticsearch
,lucene-core
andlucene-analyzer-common
according to the ones located in your ElasticSearchlib
directory. - Run
rake build
- Build copies
elasticsearch-facet-matcher.jar
to your ElasticSearchlib
directory for autoloading. - Open
/etc/elasticsearch/elasticsearch.yml
orconfig/elasticsearch.yml
and add this to the end of the file:
script.native:
facet_matcher.type: sk.opencourts.elasticsearch.FacetMatcherFactory
Note: You can change name of the facet_matcher
to any name you desire.
Restart ElasticSearch and try it out.
This searches for any value in faceted field judges.untouched
matching pattern 'peter*' by Lucene query and validates each facet value by the same query in the script.
{
"facets": {
"judges": {
"terms": {
"field": "judges.untouched",
"size": 10,
"all_terms": false,
"script": "facet_matcher",
"params": {
"query": "peter"
},
"lang": "native"
},
"global_facets": false,
"facet_filter": {
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "peter* ",
"default_operator": "and",
"analyze_wildcard": true,
"fields": [
"judges.analyzed"
]
}
}
]
}
}
}
}
}
}
}
}
- Fork it
- Create your feature branch
git checkout -b new-feature
- Commit your changes
git commit -am 'Added some feature'
- Push to the branch
git push origin new-feature
- Create new Pull Request
Copyright (c) 2013 Samuel Molnár, Pavol Zbell
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.