2017-12-18 86 views
0

我在Solr索引中有一組文檔,其中包含字段exact_title和alternative_title。我希望能夠使用字段標題進行搜索。 換句話說,查詢title:Hello World應該返回具有exact_title或alternative_title「Hello World」的文檔用於索引和查詢的Solr字段別名

是否有可能在索引期間爲字段定義別名?

+0

是這些領域的不同還是什麼?他們背後的想法是什麼? – Mysterion

+0

我有一套書,其中一些有兩個標題,一個主標題和一個替代標題。奇怪,但不是我的數據集。我希望這兩個標題都可以在同一字段下搜索,並且數據複製的數據量最小。 – orestis

回答

0

我解決了在schema.xml文件中定義複製字段。

例子:

<field name="title_txt" type="text_general" indexed="true" stored="false" multiValued="true"/> 
<field name="exact_title_txt" type="text_general" indexed="true" stored="true" multiValued="false"/> 
<field name="alternative_title_txt" type="text_general" indexed="true" stored="true" multiValued="false"/> 
<copyField source="exact_title_txt" dest="title_txt"/> 
<copyField source="alternative_title_txt" dest="title_txt"/> 
+0

由於這兩個字段的類型和內容都完全相同,所以我必須問:這能解決什麼問題? – MatsLindh

+0

我想用兩個或更多的字段搜索使用相同的傘字段 – orestis

+0

好的,當你添加更多的字段和兩個copyField指令時,它是有道理的。 – MatsLindh