I'm curious if there is any way to understand the lucene query that's generated for a particular Elasticsearch DSL query.
For example, if I create an index:
await client.indices.create({
index: 'activities',
mappings: {
dynamic: false,
properties: {
title: { type: 'search_as_you_type', analyzer: 'english' },
description: { type: 'search_as_you_type', analyzer: 'english' },
keywords: {
type: 'search_as_you_type',
analyzer: 'english',
fields: {
exact: {
type: 'keyword'
}
}
},
searchable: { type: 'boolean' }
}
}
});
]
and then query it:
{
index: 'activities',
query: {
multi_match: {
query,
type: 'bool_prefix',
minimum_should_match: "75%",
fields: [
'title^2',
'title._2gram^2',
'title._3gram^2',
'description',
'description._2gram',
'description._3gram'
]
}
}
}
There's a lot going on here. Fields are analyzed and tokenized. There's the "operator" and "min_should_match" on the bool query, and the last term is treated differently (targeting the _index_prefix
I assume, though that's implicit in the query).
I know that I can use GET /activities/_explain/5ddbf9ae009cd90bcdeaadd7
to explain the scoring for any particular document returned, but I'm curious if there's a way to see the Lucene query that's generated from this DSL. Reading through MultiMatchQueryBuilder is proving rather convoluted, though that's the best source of info on this I've found.
Is there a description of the algorithm that converts the DSL into a lucene query? Or better yet, a tool like the explain endpoint that can show me the lucene query generated from DSL?