Hi there! I am a novice in ES. And I want to know if I’m doing something wrong or trying to achieve impossible things.
I think my searches are slow. I have index messages
(22.9 GB, 77m docs). Mapping is simple:
esClient.indices.create({
index: 'messages',
body: {
mappings: {
messages: {
properties: {
hostId: {type: 'keyword'},
clientId: {type: 'keyword'},
userId: {type: 'keyword'},
createdAt: {type: 'long'},
message: {type: 'text',
fields: {
ngrams: {
type: 'text',
analyzer: 'ngrams'
}
}
}
}
}
},
settings: {
analysis: {
analyzer: {
default: {
type: 'custom',
filter: ['lowercase'],
tokenizer: 'whitespace'
},
ngrams: {
type: 'custom',
filter: ['lowercase', 'custom_edge_ngram'],
tokenizer: 'whitespace'
}
},
filter: {
custom_edge_ngram: {
type: 'edge_ngram',
min_gram: 1,
max_gram: 20,
token_chars: [
'letter',
'digit'
]
}
}
}
}
}
});
Query is simple:
esClient.search({
index: 'messages',
from: 0,
size: 10,
terminate_after: 1000,
body: {
profile,
query: {
bool: {
must: {
simple_query_string: {
query,
fields: ['message', 'message.ngrams'],
analyzer: 'whitespace',
default_operator: 'and'
}
},
filter: {
term: {hostId}
}
}
},
sort: {
_score: {order: 'desc'},
createdAt: {order: 'desc'}
}
}
}
But average response time for this index is about 1-3 sec, not quite acceptable for search-as-you-type experience. I am using Elastic Cloud (192/8gb plan). Please help!