我需要实施产品搜索。每个产品都有一个名称,一个类别,价格和价格。 availableAtPlace。我想使用这些参数进行搜索:
- product name - look for specified keywords in product name
- filter those belonging to one of the many selected categories(from fixed 8 categories only, forever)
- filter those within specified price limit.
- filter those available within radius of 'x' miles from spot 'y'
现在我有以下问题:
1. What should be the query to get the search results filtered by above parameters ?
2. Is there any way I could store these categories field in optimized
way(since this is always out of fixed set of 8 values), so that
query performance could be improved ? Probably some way of defining
my set earlier so that indexing/querying of this field could be
optimized!?
3. I need to sort the results in the order of relevance of keyword
search within product names + sorted in descending order of price.
How do I accomplish this sort order?
将SolrJ与Solr 4.5一起使用
答案 0 :(得分:1)
我会将产品名称设为默认搜索字段。
q param是要搜索的关键字
使用fq params过滤类别和价格。这些是为了提高性能而缓存的,不会在相关性排名中使用。
然后使用空间搜索半径。
这是一个搜索foo类别中“某些产品”的例子,价格在卡尔斯巴德20英里范围内,价格在200到600之间。
q=some+product&fq=category:foo&fq=price:[200+TO+600]&fq={!geofilt}&sfield=location&pt=33.1580933,-117.3505939&d=32.18688&sort=price+desc