Finding exact match using Lucene search API

后端 未结 5 1555
失恋的感觉
失恋的感觉 2021-02-09 07:06

I\'m working on a company search API using Lucene. My Lucene company index has got 2 companies: 1.Abigail Adams National Bancorp, Inc. 2.National Bancorp

If the user typ

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-09 07:47

    I have the same requirements of exact matching. I have used queryBuilder of org.hibernate.search.query.dsl and the query is:

    query = queryBuilder.phrase().withSlop(0).onField(field)
                            .sentence(searchTerm).createQuery();
    

    Its working for me.

提交回复
热议问题