Finding exact match using Lucene search API

后端 未结 5 1709
失恋的感觉
失恋的感觉 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:39

    You may want to reconsider your requirements, depending on whether or not I correctly understood your question. Please bear with me if I did misunderstand you.

    Just a little food for thought:

    • If you only want exact matches returned, then why are you searching in the first place?

    • Are you sure that the user expects exact matches? I typically search assuming that the search engine will accommodate missing words.

    • Suppose the user searched for National Bank but National Bank was no longer in your index. Would you still want Abigail Adams National Bancorp, Inc to be excluded from the results simply because it was not an exact match?

    In light of this, I would suggest you continue to present all possible matches (exact or not) to the user and let them decide for themselves which is most appropriate for them. I say this simply because you may not be thinking the same way as all of your users. Lucene will take care of making sure the closest matches rank highest in the results, helping them make quicker choices.

提交回复
热议问题