Solr does not search into integers?

前端 未结 3 636
梦如初夏
梦如初夏 2021-01-15 15:36

I\'m currently developping a search engine using Solr for an ecommerce website. So I get these two fields in my schema.xml:

   

        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 16:08

    You'll need a copyField setting for the fields you want to be searchable by default.

    Since your defaultSearchField is set to global, try:

    
    

    You'll probably want to do the same for collection:

    
    

    In order to have partial matches (e.g.: ?q=95) without special operators, you need to tweak the NGram filter. Your current setting, for both the index-time and the query-time analyzer is:

    
    

    This means that partial matching will be available from 3 to 6 characters, per example:

    • 959
    • 9596
    • 95962
    • 596
    • ...

    If you want to allow it from 2 characters (e.g.: 95), change the minGramSize in both analyzers' filters and you should be good to go:

    
    

    Lastly, your global field probably shouldn't be stored (by default) but only indexed:

    
    

    Remember that you need to restart Solr and re-index for the changes to be in effect.

提交回复
热议问题