2016-02-22 45 views
0

我有这样的数据:Solr的查询 - 不能正确文本匹配

{ 
    "id": "maxtor", 
    "compName_s": "Maxtor Corporation", 
    "address_s": "920 Disc Drive Scotts Valley, CA 95066", 
    "_version_": 1526862455621288000 
    } 

当我写这篇文章:

的Solr /核心/选择Q = compName_s%3A *迈拓* &?重量= XML &缩进=真& HL =真& hl.fl = compName_s & hl.simple.pre = & hl.simple.post = <%2Fem>

返回此:

<response> 
<lst name="responseHeader"> 
<int name="status">0</int> 
<int name="QTime">1</int> 
<lst name="params"> 
<str name="q">compName_s:*Maxtor*</str> 
<str name="hl">true</str> 
<str name="hl.simple.post"></em></str> 
<str name="indent">true</str> 
<str name="hl.fl">compName_s</str> 
<str name="wt">xml</str> 
<str name="hl.simple.pre"><em></str> 
</lst> 
</lst> 
<result name="response" numFound="1" start="0"> 
<doc> 
<str name="id">maxtor</str> 
<str name="compName_s">Maxtor Corporation</str> 
<str name="address_s">920 Disc Drive Scotts Valley, CA 95066</str> 
<long name="_version_">1526862455621287937</long> 
</doc> 
</result> 
<lst name="highlighting"> 
<lst name="maxtor"> 
<arr name="compName_s"> 
<str><em>Maxtor Corporation</em></str> 
</arr> 
</lst> 
</lst> 
</response> 

所有它的确定,但是,当我将尝试这个办法:?

的Solr /核心/选择Q = compName_s%3AMaxtor &重量= XML & indent = true & hl = true & hl.fl = compName_s & hl.simple.pre = & hl.simple.post = <%2Fem>

(compName_s:*迈拓*到compName_s:迈拓)

返回此:

<response> 
<lst name="responseHeader"> 
<int name="status">0</int> 
<int name="QTime">0</int> 
<lst name="params"> 
<str name="q">compName_s:Maxtor</str> 
<str name="hl">true</str> 
<str name="hl.simple.post"></em></str> 
<str name="indent">true</str> 
<str name="hl.fl">compName_s</str> 
<str name="wt">xml</str> 
<str name="hl.simple.pre"><em></str> 
</lst> 
</lst> 
<result name="response" numFound="0" start="0"></result> 
<lst name="highlighting"/> 
</response> 

我想回到这个:

<lst name="highlighting"> 
<lst name="maxtor"> 
<arr name="compName_s"> 
<str><em>Maxtor</em> Corporation</str> 
</arr> 
</lst> 
</lst> 

(我想只获得“迈拓”)

+0

确切的问题是什么?请问你请详细说明一下吗? –

+0

我想这个 迈拓公司 bushpop

+0

但也有没有结果那么查询如何才能得到上述格式......当您找到结果或匹配数据时会有所不同,而对于不匹配的数据则会有所不同。 –

回答

0

的你没有得到任何结果,您所期待的XML响应如下

<lst name="highlighting"> 
<lst name="maxtor"> 
<arr name="compName_s"> 
<str><em>Maxtor</em> Corporation</str> 
</arr> 
</lst> 
</lst> 

即使你的数据不匹配或情况。

然后在这种情况下,您需要挖掘相同的 solr的代码,您可以在其中修改突出显示的响应。

目前,它返回响应

<lst name="highlighting"/> 

,因为它没有找到结果集中的数据,所以其他高照明的标签是不进入画面。

对于其余标签签出源代码并检查它们如何返回响应并检查是否可以根据您的要求修改它们。