标签: solr
我现在正在使用mongodb并且它肯定不适合过滤,所以我想在这种情况下使用solr,让我好奇的是,在数据库中,如果我愿意排序或过滤值,我应该添加复合索引以使过滤器更好,在solr中,我搜索了很多,有一些叫做copyField,但我不认为这不是我的问题的答案,所以我的问题是,我应该过滤价格和城市和我应该按价格值对它们进行排序,为了这个目的我应该添加到我的模式中,或者我应该做什么?,我搜索了很多,我找不到任何东西,谢谢:)
答案 0 :(得分:2)
您需要在schema.xml
e.g。 <field name="cities" type="string" indexed="true" stored="true"/> 例如<field name="prices" type="float" indexed="true" stored="true"/>
<field name="cities" type="string" indexed="true" stored="true"/>
<field name="prices" type="float" indexed="true" stored="true"/>
如果字段有多个值,您可以将它们标记为多值。
然后,您可以使用fq过滤结果
e.g。 fq=(cities:Mumbai AND prices:100)
fq=(cities:Mumbai AND prices:100)
您还可以使用范围作为价格。
然后,您可以使用sort参数sort=prices desc
sort=prices desc