solr可以显式使用字段名称查找文档

时间:2013-07-26 10:10:25

标签: solr4

我一直在排除奇怪的Solr4.2.1查询行为,但没有成功。我有包含以下字段的架构:

<field name="primaryIndustryName_en" type="text_general" indexed="true" stored="true" multiValued="false"/>

<field name="defaultSearchField" type="text_general" indexed="true" stored="false" multiValued="true"/>

defaultSearchField是solr.SearchHandler / select requestHandler的默认字段(df)

defaultSearchField包含使用

下面的copyField的数据
<copyField source="countryName_en" dest="defaultSearchField"/>
<copyField source="plsName_en" dest="defaultSearchField"/>
<copyField source="categoryName_en" dest="defaultSearchField"/>
<copyField source="primaryIndustryName_en" dest="defaultSearchField"/>
...etc

text_general字段定义如下

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>  
        <filter class="solr.TrimFilterFactory"/>      
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
        <filter class="solr.WordDelimiterFilterFactory"
                splitOnNumerics="1"
                splitOnCaseChange="0"
                stemEnglishPossessive="0"               
                generateWordParts="1"
                generateNumberParts="1"
                catenateWords="0"
                catenateNumbers="0"
                catenateAll="0"
                preserveOriginal="1"                
                protected="protwords.txt"/> 
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <charFilter class="solr.HTMLStripCharFilterFactory"/>        
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.TrimFilterFactory"/>                
        <filter class="solr.WordDelimiterFilterFactory"
                splitOnNumerics="1"
                splitOnCaseChange="0"
                stemEnglishPossessive="0"               
                generateWordParts="1"
                generateNumberParts="1"
                catenateWords="0"
                catenateNumbers="0"
                catenateAll="0"
                preserveOriginal="1"                
                protected="protwords.txt"/>

        <filter class="solr.HunspellStemFilterFactory"
                dictionary="en_US.dic"
                affix="en_US.aff"
                ignoreCase="true" />
      </analyzer>
    </fieldType>

现在如果我搜索餐厅&amp;咖啡馆和countryId:1 我得到了正确的文件(基本上所有的商店都是“餐馆和咖啡馆”) 。但如果我明确搜索 primaryIndustryName_en:“restaurant&amp; cafes”AND countryId:1 ,我会得到一个空的结果列表。对于大写和小写的相同行为。请注意,我使用的是edismax解析器,所有查询都是通过SolrJ

完成的

下面是文档输出

<doc>
    <int name="brateCount">0</int>
    <str name="outletPrimaryName">La Maison Du Cafe (Cafe Najjar)</str>
    <str name="outletId">734</str>
    <str name="outletPhone1">+961-1-346646</str>
    <str name="outletUrl">www.lamaisonducafenajjar.com</str>
    <double name="outletAvarageRating">0.0</double>
    <str name="outletAddress">Hamra Main Street</str>
    <int name="views">0</int>
    <int name="areaId">1</int>
    <str name="facetAreaName_en">Hamra</str>
    <str name="areaName_en">Hamra</str>
    <str name="areaName_ar">Hamra</str>
    <str name="facetAreaName_ar">Hamra</str>
    <str name="areaName_fr">Hamra</str>
    <str name="facetAreaName_fr">Hamra</str>
    <int name="cityId">1</int>
    <str name="cityName_en">Beirut</str>
    <str name="facetCityName_en">Beirut</str>
    <str name="facetCityName_ar">Beirut</str>
    <str name="cityName_ar">Beirut</str>
    <str name="cityName_fr">Beirut</str>
    <str name="facetCityName_fr">Beirut</str>
    <int name="countryId">1</int>
    <str name="countryCode">LB</str>
    <str name="countryName_en">Lebanon</str>
    <str name="countryName_ar">Lebanon</str>
    <str name="countryName_fr">Lebanon</str>
    <int name="primaryIndustryId">55</int>
    <str name="primaryIndustryName_en">Restaurants & Cafes</str>
    <str name="facetPrimaryIndustryName_en">Restaurants & Cafes</str>
    <str name="primaryIndustryName_ar">Restaurants & Cafes</str>
    <str name="facetPrimaryIndustryName_ar">Restaurants & Cafes</str>
    <str name="primaryIndustryName_fr">Restaurants & Cafes</str>
    <str name="facetPrimaryIndustryName_fr">Restaurants & Cafes</str>
    <int name="primaryCategoryId">114</int>
    <str name="primaryCategoryName_en">Coffee Shops</str>
    <str name="facetPrimaryCategoryName_en">Coffee Shops</str>
    <str name="facetPrimaryCategoryName_ar">Coffee Shops</str>
    <str name="primaryCategoryName_ar">Coffee Shops</str>
    <str name="primaryCategoryName_fr">Coffee Shops</str>
    <str name="facetPrimaryCategoryName_fr">Coffee Shops</str>
    <arr name="ratingId">
      <int>10</int>
      <int>11</int>
      <int>12</int>
      <int>13</int>
      <int>15</int>
      <int>9</int>
    </arr>
    <arr name="ratingName_en">
      <str>Drinks</str>
      <str>Service</str>
      <str>Value</str>
      <str>Atmosphere</str>
      <str>Cleanliness</str>
      <str>Food</str>
    </arr>
    <arr name="ratingName_ar">
      <str>Drinks</str>
      <str>Service</str>
      <str>Value</str>
      <str>Atmosphere</str>
      <str>Cleanliness</str>
      <str>Food</str>
    </arr>
    <arr name="ratingName_fr">
      <str>Drinks</str>
      <str>Service</str>
      <str>Value</str>
      <str>Atmosphere</str>
      <str>Cleanliness</str>
      <str>Food</str>
    </arr>
    <arr name="plsId">
      <int>52</int>
      <int>53</int>
      <int>54</int>
      <int>55</int>
      <int>56</int>
      <int>58</int>
      <int>60</int>
      <int>61</int>
      <int>84</int>
      <int>85</int>
      <int>119</int>
    </arr>
    <arr name="plsName_en">
      <str>Water</str>
      <str>Juice</str>
      <str>Soft Drink</str>
      <str>Coffee</str>
      <str>Tea</str>
      <str>Smoothie</str>
      <str>Hot Chocolate</str>
      <str>Energy Drink</str>
      <str>Salad</str>
      <str>Sandwich</str>
      <str>Dessert</str>
    </arr>
    <arr name="plsName_ar">
      <str>Water</str>
      <str>Juice</str>
      <str>Soft Drink</str>
      <str>Coffee</str>
      <str>Tea</str>
      <str>Smoothie</str>
      <str>Hot Chocolate</str>
      <str>Energy Drink</str>
      <str>Salad</str>
      <str>Sandwich</str>
      <str>Dessert</str>
    </arr>
    <arr name="plsName_fr">
      <str>Water</str>
      <str>Juice</str>
      <str>Soft Drink</str>
      <str>Coffee</str>
      <str>Tea</str>
      <str>Smoothie</str>
      <str>Hot Chocolate</str>
      <str>Energy Drink</str>
      <str>Salad</str>
      <str>Sandwich</str>
      <str>Dessert</str>
    </arr>
    <long name="_version_">1441614839971577856</long></doc>

任何想法可能是什么问题?

1 个答案:

答案 0 :(得分:0)

我尝试使用您使用的相同配置。您在查询部分中为 text_general 添加的过滤器所遇到的问题。

<filter class="solr.HunspellStemFilterFactory"
                dictionary="en_US.dic"
                affix="en_US.aff"
                ignoreCase="true" />

我删除了过滤器并且工作正常。