时,它也可以在文档之间进行连接。
我试图在solr中搜索,但我想优先考虑搜索一个字段(即标题)超过其他字段的匹配,如"董事"。这是schema。xml
的一部分<fields>
<field name="Id" type="string" indexed="true" stored="true" required="true"/>
<field name="Title" type="text_general" indexed="true" stored="true"/>
<field name="OriginalTitle" type="text_general" indexed="true" stored="true"/>
<field name="Directors" type="text_general" indexed="true" stored="true" multiValued="true" required="false"/>
<field name="Language" type="text_general" indexed="false" stored="true" required="false"/>
<field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>
</fields>
<uniqueKey>Id</uniqueKey>
<defaultSearchField>text</defaultSearchField>
<solrQueryParser defaultOperator="OR"/>
<copyField source="Title" dest="text"/>
<copyField source="OriginalTitle" dest="text"/>
<copyField source="Directors" dest="text"/>
<copyField source="Keywords" dest="text"/>
这是我的请求处理器:
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
<lst name="params">
<str name="lowercaseOperators">true</str>
<str name="pf">Title^100 Directors^10</str>
<str name="indent">true</str>
<str name="q">fo*</str>
<str name="qf">Title Directors</str>
<str name="stopwords">true</str>
<str name="wt">xml</str>
<str name="defType">edismax</str>
</lst>
</lst>
我的结果是:
<result name="response" numFound="4" start="0">
<doc>
<str name="Language">Ingles subtítulos español</str>
<str name="Title">Footloose</str>
<arr name="Directors">
<str>Herbert Ross</str>
</arr>
<str name="OriginalTitle">Footloose (1984)</str>
</doc>
<doc>
<str name="Language">Ingles subtítulos español</str>
<str name="Title">Amadeus</str>
<arr name="Directors">
<str>Milos Forman</str>
</arr>
<str name="OriginalTitle">Amadeus</str>
</doc>
<doc>
<str name="Language">Ingles subtítulos español</str>
<str name="Title">Forrest Gump</str>
<arr name="Directors">
<str>Robert Zemeckis</str>
</arr>
<str name="OriginalTitle">Forrest Gump</str>
</doc>
<doc>
<str name="Language">Doblado al español</str>
<str name="Title">Chimpancés</str>
<arr name="Directors">
<str>Alastair Fothergill</str>
<str> Mark Linfield</str>
</arr>
<str name="OriginalTitle">Chimpanzee Esp</str>
</doc>
</result>
但是我想要这个结果:
<result name="response" numFound="4" start="0">
<doc>
<str name="Language">Ingles subtítulos español</str>
<str name="Title">Footloose</str>
<arr name="Directors">
<str>Herbert Ross</str>
</arr>
<str name="OriginalTitle">Footloose (1984)</str>
</doc>
<doc>
<str name="Language">Ingles subtítulos español</str>
<str name="Title">Forrest Gump</str>
<arr name="Directors">
<str>Robert Zemeckis</str>
</arr>
<str name="OriginalTitle">Forrest Gump</str>
</doc>
<doc>
<str name="Language">Ingles subtítulos español</str>
<str name="Title">Amadeus</str>
<arr name="Directors">
<str>Milos Forman</str>
</arr>
<str name="OriginalTitle">Amadeus</str>
</doc>
<doc>
<str name="Language">Doblado al español</str>
<str name="Title">Chimpancés</str>
<arr name="Directors">
<str>Alastair Fothergill</str>
<str> Mark Linfield</str>
</arr>
<str name="OriginalTitle">Chimpanzee Esp</str>
</doc>
</result>
我应该怎么做在我的查询得到我想要的响应??
:关于debug=True,我得到了这样的结果:
<lst name="debug">
<str name="rawquerystring">fo*</str>
<str name="querystring">fo*</str>
<str name="parsedquery">
(+DisjunctionMaxQuery((Directors:fo* | Title:fo*)) () ())/no_coord
</str>
<str name="parsedquery_toString">+(Directors:fo* | Title:fo*) () ()</str>
<lst name="explain">
<str name="10">
1.0 = (MATCH) sum of: 1.0 = (MATCH) max of: 1.0 = (MATCH) ConstantScore(Title:fo*), product of: 1.0 = boost 1.0 = queryNorm
</str>
<str name="2">
1.0 = (MATCH) sum of: 1.0 = (MATCH) max of: 1.0 = (MATCH) ConstantScore(Directors:fo*), product of: 1.0 = boost 1.0 = queryNorm
</str>
<str name="12">
1.0 = (MATCH) sum of: 1.0 = (MATCH) max of: 1.0 = (MATCH) ConstantScore(Title:fo*), product of: 1.0 = boost 1.0 = queryNorm
</str>
<str name="711">
1.0 = (MATCH) sum of: 1.0 = (MATCH) max of: 1.0 = (MATCH) ConstantScore(Directors:fo*), product of: 1.0 = boost 1.0 = queryNorm
</str>
</lst>
<str name="QParser">ExtendedDismaxQParser</str>
<null name="altquerystring"/>
<null name="boost_queries"/>
<arr name="parsed_boost_queries"/>
<null name="boostfuncs"/>
<lst name="timing">
<double name="time">4.0</double>
<lst name="prepare">
<double name="time">1.0</double>
<lst name="query">
<double name="time">1.0</double>
</lst>
<lst name="facet">
<double name="time">0.0</double>
</lst>
<lst name="mlt">
<double name="time">0.0</double>
</lst>
<lst name="highlight">
<double name="time">0.0</double>
</lst>
<lst name="stats">
<double name="time">0.0</double>
</lst>
<lst name="debug">
<double name="time">0.0</double>
</lst>
</lst>
<lst name="process">
<double name="time">3.0</double>
<lst name="query">
<double name="time">0.0</double>
</lst>
<lst name="facet">
<double name="time">0.0</double>
</lst>
<lst name="mlt">
<double name="time">0.0</double>
</lst>
<lst name="highlight">
<double name="time">0.0</double>
</lst>
<lst name="stats">
<double name="time">0.0</double>
</lst>
<lst name="debug">
<double name="time">3.0</double>
</lst>
</lst>
</lst>
</lst>
您正在提高您的短语字段匹配,但不是您的查询字段匹配。您可能想要提升所有,特别是因为您的搜索实际上不是一个短语:
<str name="pf">Title^100 Directors^10</str>
<str name="qf">Title Directors</str>
尝试将相同的权重放在qf字段。
您应该尝试做一个解释(但是debug=true或debugQuery=trueto querystring)来查看查询得分的元素。看起来可能是频率之类的词造成了差异。当你没有太多的内容