我正在尝试在 solr 中搜索,但我想优先搜索字段(即标题)而不是其他字段(如“Directors”)中的匹配。这是我的 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>
我应该在我的查询中做什么以获得我想要的响应?
更新:关于调试=真,我得到了这个结果:
<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>