Use this aggregation:
{
"aggregations": {
"result": {
"terms": {
"field": "author.display_name.keyword",
"size": 100,
"include": "(R.* J.*)|(J.* R.*)"
}
}
},
"size": 0,
"from": 0
}
For the following three queries:
q=author.display_name:(richard~2 jefferson~2)
q=author.display_name:("richard jefferson")
q=((author.display_name:(richard*) AND author.display_name:(*jefferson))) OR ((author.display_name:(richard*) AND author.display_name:(jefferson*)))
Combine and deduplicate the results of all 3 aggregations
Modify the results of aggregation to include a new field, noMiddleNames
which is just the first and last word for each.
So "George R R Martin" just becomes "George Martin"
Run list through this local Fuse fuzzy search:
{
shouldSort: true,
tokenize: true,
matchAllTokens: true,
findAllMatches: true,
location: 0,
distance: 100,
maxPatternLength: 32,
keys: [
{
name: 'key',
weight: 1,
},
{
name: 'noMiddleNames',
weight: 0.5,
},
],
}