我是Solr的新手。 我做了以下事情。 i)完成Java虚拟机和Tomcat Apache for Solr的安装。 ii)a)以下列方式配置Schema.xml。
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="example" version="1.5">
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="_root_" type="string" indexed="true" stored="false"/>
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="productid" type="long" indexed="true" stored="true" required="true" multiValued="false" />
<field name="catalogitemno" type="string" indexed="true" stored="true" required="false" multiValued="false" />
<field name="string_value" type="string" indexed="true" stored="true" required="false" multiValued="true" />
<field name="numeric_value" type="string" indexed="true" stored="true" required="false" multiValued="false" />
<field name="attributeid" type="string" indexed="true" stored="true" required="false" multiValued="false" />
<field name="datatype" type="string" indexed="true" stored="true" required="false" multiValued="false" />
<uniqueKey>id</uniqueKey>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
</schema>
b)按以下方式配置SolrConfig.xml并包含DataImport。
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
<lib dir="${solr.install.dir:}/dih/" regex=".*\.jar" />
c)按以下方式配置data-config.xml。
<span style="font-family: Trebuchet MS, sans-serif;">
<dataConfig>
<script><![CDATA[
function f1(row) {
var SplitString = row.get("string_value");
if(SplitString!== null){
var _SplitString = SplitString.split(',');
row.put("string_value",_SplitString);
}
return row;
}
]]>
</script>
<dataSource type="JdbcDataSource"
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://ServerName;databaseName=ABCX;"
user="sa"
password="xxxxx"
batchSize="1" />
<document name="cd2">
<entity name="PAtt" transformer="script:f1" query="SELECT ROW_NUMBER() over( order by pro.productid asc) as 'id'
,pro.ProductID as 'productid'
,pro.CatalogItemNo as 'catalogitemno'
,pav.String_Value as 'string_value'
,pav.Numeric_Value as 'numeric_value'
,pav.AttributeID as 'attributeid'
,pav.DataType as 'datatype'
FROM [retail].[Product] pro inner join retail.ProductAttributesValues pav on pav.ProductID = pro.ProductID;">
<field column="id" name="id" />
<field column="productid" name="productid" />
<field column="catalogitemno" name="catalogitemno" />
<field column="string_value" name="string_value" />
<field column="numeric_value" name="numeric_value" />
<field column="attributeid" name="attributeid" />
<field column="datatype" name="datatype" />
</entity>
</document>
</dataConfig>
</span>
iii)索引已创建,我在dataImport查询窗口中得到以下结果。有关参考,请参阅以下屏幕截图。
现在我的问题是, 我如何在MVC控制器中获得屏幕截图Solr DataImport结果?如何做到这一点。有没有人这样做过?需要你的帮助...