You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Jan Høydahl <ja...@cominvent.com> on 2021/08/26 12:21:08 UTC
JSON Query DSL and Span Queries
Hi
I have this XMLParser query that works well that I'd like to convert to JSON Query DSL:
<BooleanQuery fieldName="content">
<Clause occurs="must">
<TermQuery>erna</TermQuery>
</Clause>
<Clause occurs="should">
<SpanFirst end="100" boost="1">
<SpanTerm>solberg</SpanTerm>
</SpanFirst>
</Clause>
</BooleanQuery>
What it does is require term "erna" in content field, but give a higher boost if the term "solberg" is within first 100 terms.
So I tried something like this
{
"query": {
"bool": {
"must": [
{
"lucene": {
"df": "content",
"query": "erna"
}
}
],
"should": [
{
"spanFirst": {
"end": 100,
"boost": 1,
"query": {
"spanTerm": {
"term": "solberg"
}
}
}
}
]
}
}
}
The "must" part works, but the problem is that it cannot find the "spanFirst" parser because it is not registered in the static map in QParserPlugin (https://github.com/apache/solr/blob/main/solr/core/src/java/org/apache/solr/search/QParserPlugin.java#L48:L91)
We don't even seem to have a QParserPlugin class for the Span* family of queries.
So what is the road forward here to support any kind of sub queries in JSON DSL? The documentation is a bit lacking here.
Jan