NEST search by guid returning more documentes, how to escape "-" char?

I am doing a search by a guid but it returns more documents not matching the full guid.

If i search for: 333-600-123-334 it returns any doc containing 600 per example. How can i match the full guid string?

        var result = elk.Search<xxxDto>(x => x
            .From(0)
            .Index("index-*")
            .Size(300)
            .AllTypes()
            .Query(q =>
                q.Match(qs => qs.Field("asset_tag").Query("333-600-123-334)))
            .Sort(ss => ss.Descending(p => p.sort_start_time))
            );

Any tip for this? on how to escape "-"?

I am trying to use this: but generates invalid response.

query_string = "SNMPv2 - SMI::enterprises.21865.1.1.6: "333-600-123-334"";
q.QueryString(qs => qs.Query(query_string)))

This worksbut returns any doc containing 333 or 666 or 123, etc:

q.Match(qs => qs.Field("SNMPv2-SMI::enterprises.21865.1.1.6").Query("333-600-123-334")))

I believe the problem here is that your guids are tokenised by the -, and the query is also being tokenised, so it's finding partial matches for you.

What you want is to match the exact query text, which you can do using a constant_score query. See this article for details.

If you're only ever going to query exact guid matches, then you could also disable tokenisation for that field to save some index space.

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