我正在使用DIH索引从solr到mongo的文档,我的数据如下所示
{" _id" :" processedSKU_ID-1"," clientName" :" client1", " searchQueryAnalysisObj" :[{" searchKeyword" :" iphone 1", " searchKeywordScore" :1.8000000000000003},{" searchKeyword" : " iphone 2"," searchKeywordScore" :5.400000000000001},{ " searchKeyword" :" iphone 3"," searchKeywordScore" : 1.8000000000000003},{" searchKeyword" :" iphone 4"," searchKeywordScore" :0.9000000000000001}]," _class" : " com.unilog.model.MainClickStreamData" }
我想获取每个searchKeyword和searchKeywordScore并将其放入solr中
" searchKeyword_1" :" iphone 1"," searchKeywordScore_1" : 1.8000000000000003 searchKeyword_2" :" iphone 2"," searchKeywordScore_2" :5.400000000000001" searchKeyword_3" :" iphone 3"," searchKeywordScore_3" :1.8000000000000003 ...........
searchKeyword和searchKeywordScore是我的searchIndex中的动态字段,因此我可以推送尽可能多的searchKeyword和searchKeywordScore
以及ID和客户端名称。 ID和客户端名称我能够成功编制索引,但问题是我无法索引searchQueryAnalysisObj这是对象的arrylist。
我正在做这样的事情
<entity name="thisg" processor="MongoEntityProcessor" query="" collection="clickStreamProcessed" datasource="MyMongo" transformer="script:hello"> <field name="clientName" column="clientName" /> <field name="id" column="_id" /> </entity> </document>
&lt; ![CDATA [ function hello(row){ if(row.get(&#39; searchQueryAnalysisObj&#39;)!== null)
{var a = row.get(&#39; searchQueryAnalysisObj&#39;);
for(a.searchQueryAnalysisObj中的var键) {
row.put(&#34;猫&#34;,row.get(&#34; _class&#34;。)的toString());
var num = key +1;
var fieldName1 =&#34; searchKeyword&#34; + num;
var fieldName2 =&#34; searchKeywordScore&#34; + num; row.put(fieldName1,a.searchQueryAnalysisObj [key] [&#34; searchKeyword&#34;]);
row.put(fieldName2,a.searchQueryAnalysisObj [key] [&#34; searchKeywordScore&#34;]); }}返回行;
}]]&gt;
任何人都可以在我做错的地方帮助我吗?