mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Allow wildcards in query filter
This commit is contained in:
parent
b2c115f9d9
commit
b57ccd0616
1 changed files with 15 additions and 1 deletions
|
|
@ -27,10 +27,24 @@ import {
|
||||||
} from './types'
|
} from './types'
|
||||||
|
|
||||||
const appendQuery = (builder: ESBuilder, query: string): ESBuilder => {
|
const appendQuery = (builder: ESBuilder, query: string): ESBuilder => {
|
||||||
|
const fields = ['title', 'content', 'author', 'description', 'siteName']
|
||||||
|
if (query.includes('*')) {
|
||||||
|
// wildcard query
|
||||||
|
fields.forEach((field) => {
|
||||||
|
builder = builder.orQuery('wildcard', {
|
||||||
|
[field]: {
|
||||||
|
value: query,
|
||||||
|
case_insensitive: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return builder.queryMinimumShouldMatch(1)
|
||||||
|
}
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
.orQuery('multi_match', {
|
.orQuery('multi_match', {
|
||||||
query,
|
query,
|
||||||
fields: ['title', 'content', 'author', 'description', 'siteName'],
|
fields,
|
||||||
operator: 'and',
|
operator: 'and',
|
||||||
type: 'cross_fields',
|
type: 'cross_fields',
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue