2016-11-26 39 views
1

我试图使用Spring Data Solr查询来自后端Solr服务器的东西,它具有以下schema.xml(显示您只是字段为简单起见),它是从Nutch schema.xml复制的。这意味着,我已经爬到使用Nutch的网页,然后通过细分到Solr:Solr字段在Spring Data Solr中如何映射?

... 

<fields> 

    <!--APPARENTLY THE ONLY FIELD WHICH IS REQUIRED!!! --> 
    <field name="id" type="string" stored="true" indexed="true" required="true"/> 

    <field name="_version_" type="long" indexed="true" stored="true"/> 

    <!-- core fields --> 
    <field name="segment" type="string" stored="true" indexed="false"/> 
    <field name="digest" type="string" stored="true" indexed="false"/> 
    <field name="boost" type="float" stored="true" indexed="false"/> 

    <!-- fields for index-basic plugin --> 
    <field name="host" type="url" stored="false" indexed="true"/> 
    <field name="url" type="url" stored="true" indexed="true"/> 
    <!-- stored=true for highlighting, use term vectors and positions for fast highlighting --> 
    <field name="content" type="text_general" stored="true" indexed="true"/> 
    <field name="title" type="text_general" stored="true" indexed="true"/> 
    <field name="cache" type="string" stored="true" indexed="false"/> 
    <field name="tstamp" type="date" stored="true" indexed="false"/> 

    <!-- fields for index-geoip plugin --> 
    <field name="ip" type="string" stored="true" indexed="true"/> 
    <field name="cityName" type="string" stored="true" indexed="true"/> 
    <field name="cityConfidence" type="int" stored="true" indexed="true"/> 
    <field name="cityGeoNameId" type="int" stored="true" indexed="true"/> 
    <field name="continentCode" type="string" stored="true" indexed="true"/> 
    <field name="continentGeoNameId" type="int" stored="true" indexed="true"/> 
    <field name="contentName" type="string" stored="true" indexed="true"/> 
    <field name="countryIsoCode" type="string" stored="true" indexed="true"/> 
    <field name="countryName" type="string" stored="true" indexed="true"/> 
    <field name="countryConfidence" type="int" stored="true" indexed="true"/> 
    <field name="countryGeoNameId" type="int" stored="true" indexed="true"/> 
    <field name="latLon" type="string" stored="true" indexed="true"/> 
    <field name="accRadius" type="int" stored="true" indexed="true"/> 
    <field name="timeZone" type="string" stored="true" indexed="true"/> 
    <field name="metroCode" type="int" stored="true" indexed="true"/> 
    <field name="postalCode" type="string" stored="true" indexed="true"/> 
    <field name="postalConfidence" type="int" stored="true" indexed="true"/> 
    <field name="countryType" type="string" stored="true" indexed="true"/> 
    <field name="subDivName" type="string" stored="true" indexed="true"/> 
    <field name="subDivIsoCode" type="string" stored="true" indexed="true"/> 
    <field name="subDivConfidence" type="int" stored="true" indexed="true"/> 
    <field name="subDivGeoNameId" type="int" stored="true" indexed="true"/> 
    <field name="autonSystemNum" type="int" stored="true" indexed="true"/> 
    <field name="autonSystemOrg" type="string" stored="true" indexed="true"/> 
    <field name="domain" type="string" stored="true" indexed="true"/> 
    <field name="isp" type="string" stored="true" indexed="true"/> 
    <field name="org" type="string" stored="true" indexed="true"/> 
    <field name="userType" type="string" stored="true" indexed="true"/> 
    <field name="isAnonProxy" type="boolean" stored="true" indexed="true"/> 
    <field name="isSatelitteProv" type="boolean" stored="true" indexed="true"/> 
    <field name="connType" type="string" stored="true" indexed="true"/> 
    <field name="location" type="location" stored="true" indexed="true"/> 

    <dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false"/> 

    <!-- catch-all field --> 
    <field name="text" type="text_general" stored="false" indexed="true" multiValued="true"/> 

    <!-- fields for index-anchor plugin --> 
    <field name="anchor" type="text_general" stored="true" indexed="true" multiValued="true"/> 

    <!-- fields for index-more plugin --> 
    <field name="type" type="string" stored="true" indexed="true" multiValued="true"/> 
    <field name="contentLength" type="string" stored="true" indexed="false"/> 
    <field name="lastModified" type="date" stored="true" indexed="false"/> 
    <field name="date" type="tdate" stored="true" indexed="true"/> 

    <!-- fields for languageidentifier plugin --> 
    <field name="lang" type="string" stored="true" indexed="true"/> 

    <!-- fields for subcollection plugin --> 
    <field name="subcollection" type="string" stored="true" indexed="true" multiValued="true"/> 

    <!-- fields for feed plugin (tag is also used by microformats-reltag)--> 
    <field name="author" type="string" stored="true" indexed="true"/> 
    <field name="tag" type="string" stored="true" indexed="true" multiValued="true"/> 
    <field name="feed" type="string" stored="true" indexed="true"/> 
    <field name="publishedDate" type="date" stored="true" indexed="true"/> 
    <field name="updatedDate" type="date" stored="true" indexed="true"/> 

    <!-- fields for creativecommons plugin --> 
    <field name="cc" type="string" stored="true" indexed="true" multiValued="true"/> 

    <!-- fields for tld plugin --> 
    <field name="tld" type="string" stored="false" indexed="false"/> 

    <!-- field containing segment's raw binary content if indexed with -addBinaryContent --> 
    <field name="binaryContent" type="binary" stored="true" indexed="false"/> 

</fields> 

... 

现在,看着春数据Solr的文档,例如这里:

http://docs.spring.io/spring-data/solr/docs/1.4.x/reference/html/#reference

他们使用的方法和字段似乎与我的模式中的字段不匹配。例如,在文档它们有:

public interface ProductRepository extends Repository<Product, String> { 
    List<Product> findByNameAndPopularity(String name, Integer popularity); 
} 

public interface ProductRepository extends SolrRepository<Product, String> { 
    @Query("inStock:?0") 
    List<Product> findByAvailable(Boolean available); 
} 

而且在看我的领域我没有任何所谓的“名”,“人气”或“可用”的字段。我错过了什么?我应该改变我的模式吗?我应该从文档更改存储库吗?

这最后一个问题看起来很愚蠢,但由于我见过的使用Spring Data Solr的示例仅创建Product模型(我知道它是一个示例,但示例通常反映了默认情况!)以及它们相应的Solr存储库,通常包含诸如“名称”,“流行度”,“作者”等字段,我不确定这些字段实际代表或映射到的是什么。

回答

相关问题