Solr ALPHABETICAL RANGE QUERY

橙三吉。 提交于 2021-02-08 10:40:21

问题


I am trying implement an alphabetical range to perform a query in Solr 3.3. The user wants to fetch a list of restaurants which names start with (for example) A to G. Tried with "frange" function but it includes every field that has the letter. I want to get the restaurants wich names START with a specific letter.

Something like: "Get all restaurants from A to G": (A* and G*) but not (a and g).

Thank you


回答1:


Use name:[a TO h] where name field is not tokenized. If required, create a separate copy of the field for this.

If you try this on a tokenized field, then it will match all names which contain a word which starts with one of these letters. Also, you need to 'increment' the last letter of the range. If it is z, then replace it with *. For example, if the user is looking for w to z then the query should be name:[w TO *].




回答2:


Have you tried name:[a TO g] ?



来源:https://stackoverflow.com/questions/8883419/solr-alphabetical-range-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!