我已经为电子商务商店实施了Solr Search and Faceting,并面临与facet过滤器分面结果相关的问题.只有当我们在facet字段中有特殊字符(即括号)时才会发生这种情况,否则一切正常.
我使用SolrNet实现了这一点.我检查了直接对Solr进行原始查询,发现这个问题可能在Solr本身,而与SolrNet无关.
例:
我有很多产品和过滤器如下:
RAM (GB)
2 GB
4 GB
8 GB
Memory (GB)
4 GB
8 GB
16 GB
Run Code Online (Sandbox Code Playgroud)
每个方面选项都有一些产品,所以问题不在于facet.min计数.我也正确地应用了标记.
现在,其中一个方面工作正常,而另一个方面似乎不能在方面字段中使用括号.
这是我定义facet字段的架构.
<dynamicField name="f_*" type="string" indexed="true" stored="true" multiValued="true" required="false" />
<dynamicField name="pa_*" type="string" indexed="true" stored="true" multiValued="true" required="false" />
Run Code Online (Sandbox Code Playgroud)
当我以pa_查询字段时,Facet工作正常,但不是f_.
查询我正在进入Solr:
../select?indent=on&wt=json&facet.field={!ex%3Dpa_RAM(GB)}pa_RAM(GB)&fq={!tag%3Dpa_RAM\(GB\)}pa_RAM\(GB\):2%2BGB&q=CategoryID:(1+OR+2+OR+3+OR+4)&start=0&rows=10&defType=edismax&facet.mincount=1&facet=true&spellcheck.collate=true
Run Code Online (Sandbox Code Playgroud)
这可以正常工作.
另一个疑问:
../select?indent=on&wt=json&facet.field={!ex%3Df_Memory(GB)}f_Memory(GB)&fq={!tag%3Df_Memory\(GB\)}f_Memory\(GB\):4%2BGB&q=CategoryID:(1+OR+2+OR+3+OR+4)&start=0&rows=10&defType=edismax&facet.mincount=1&facet=true&spellcheck.collate=true
Run Code Online (Sandbox Code Playgroud)
给出以下结果:
这不起作用.但是,如果我从查询和索引数据中删除特殊字符,这可以正常工作.
此外,返回的facet选项是我添加过滤器标签的选定选项.Solr不会返回所有其他方面选项.
我无法弄清楚为什么会发生这种情况以及如何解决这个问题.
任何线索\想法都会很棒!
请参考此查询和图像.(这不是正确的方法或完美的解决方案)
../select?indent=on&wt=json&facet.field={!ex%3Df_Memory(GB)}f_Memory(GB)&fq={!tag%3Df_Memory(GB)}f_Memory\(GB\):4%2BGB&q=CategoryID:(1+OR+2+OR+3+OR+4)&start=0&rows=10&defType=edismax&facet.mincount=1&facet=true&spellcheck.collate=true&fl=Id,Name,f_Memory(GB)
Run Code Online (Sandbox Code Playgroud)
参考链接:Faceting的本地参数
请帮我!
如何删除字符串数组中的单词
var array= new string []
{"windows!!1!!","dual+sim!!3!!","32+gb!!2!!","Intel+i5!!2!!"};
Run Code Online (Sandbox Code Playgroud)
输出数组
var Output-array= new string []
{"windows","dual sim","32 gb","Intel i5"};
Run Code Online (Sandbox Code Playgroud)
怎么能在C#的单行代码中这样做