fuzzy search in bleve

621 Views Asked by At

I have come up below code but not to sure how to move forward.

In short I am trying get result for such case,

When searched "ome" i need "bbb something aaa" to be found. Have tried to add tq.SetFuzziness(5) but this causes ap to crash without any error. I would appreciate any help.

    param := c.DefaultQuery("param", "")

    split := strings.Split(param, " ")

    tqs := make([]query.Query, len(split))
    for i, token := range split {
        tq := bleve.NewFuzzyQuery(token)
        tq.SetField("Content")
        //tq.SetFuzziness(5) this line cause error.
        tqs[i] = tq
    }

    allQuery := bleve.NewConjunctionQuery(tqs...)

    req := bleve.NewSearchRequest(allQuery)
    req.Highlight = bleve.NewHighlightWithStyle("html")
    req.Fields = []string{"ID", "Title", "Content", "RawContent"}
    res, err := index.Search(req)
0

There are 0 best solutions below