Using fuzziness in span queries

I try to implement a search for a phrase by using a span query as I found at stackoverflow:

But I have to write it as a request for NEST in VB.NET:

Dim sSpanClauses As New List(Of ISpanQuery)
For Each w In word.Split(" ")
    sSpanClauses.Add(New SpanMultiTermQuery() With {
        .Match = New MatchQuery() With {
            .Field = p.searchField,
            .Query = w,
            .Fuzziness = Fuzziness.EditDistance(p.fuzziness),
            .PrefixLength = 1
    }})
Next


Dim sPhrase As New BoolQuery() With {
    .Should = New SpanNearQuery() With {
        .Clauses = sSpanClauses,
        .Slop = 2,
        .InOrder = True
    }
}

The problem is that SpanNearQuery.Clauses expect an Enumarable Of(ISpanQuery) but I have to use SpanMultiTermQuery to implement fuzziness. SpanMultiTermQuery can not be added to a List(of ISpanQuery).

Where is my fault?

Regards
Stefan

Ok... maybe on the right way.

Dim sSpanClauses As New List(Of ISpanQuery)
Dim sSpanNearClause As New List(Of QueryContainer)

For Each w In word.Split(" ")
    sSpanClauses.Add(New SpanQuery() With {
        .SpanMultiTerm = New SpanMultiTermQuery() With {
        .Match = New MatchQuery() With {
            .Field = p.searchField,
            .Query = w,
            .Fuzziness = Fuzziness.EditDistance(p.fuzziness),
            .PrefixLength = 1
    }}})
Next

sSpanNearClause.Add(New SpanNearQuery() With {
        .Clauses = sSpanClauses,
        .Slop = 2,
        .InOrder = True
    })

Dim sPhraseQuery As New BoolQuery() With {
    .Must = sSpanNearClause
}

innerQuerieClauses.Add(sPhraseQuery)

But this generates an empty search request at the end.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.