1

我需要实现产品搜索。每个产品都有名称、类别、价格和 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 一起使用

4

1 回答 1

1

我会将产品名称设为默认搜索字段。

q 参数将是要搜索的关键字

使用 fq 参数过滤类别和价格。这些是为了性能而缓存的,不用于相关性排名。

然后使用空间搜索半径。

这是一个在距离卡尔斯巴德 20 英里范围内搜索 foo 类别中价格在 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

于 2013-10-04T14:45:11.097 回答