Apache solr。查询语法说明

时间:2014-01-15 13:40:53

标签: java solr

我搞乱了语法q查询:

  1. 如果我写q=*:* - 我看到2个结果。

  2. 如果我跳过q - 我没有看到任何内容

  3. 如果我写q=price:* - 请参阅2结果

  4. 如果我写q=price - 0结果

  5. 更新

    1. q=price:0 - 1个结果
    2. 您能解释这些查询之间的差异吗?

      特别是我想了解第4个变种是什么意思?

      索引文件:

      add><doc>
        <field name="id">3007WFP</field>
        <field name="name">Dell Widescreen UltraSharp 3007WFP</field>
        <field name="manu">Dell, Inc.</field>
        <!-- Join -->
        <field name="manu_id_s">dell</field>
        <field name="cat">electronics</field>
        <field name="cat">monitor</field>
        <field name="features">30" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast</field>
        <field name="includes">USB cable</field>
        <field name="weight">401.6</field>
        <field name="price">2199</field>
        <field name="popularity">6</field>
        <field name="inStock">true</field>
        <!-- Buffalo store -->
        <field name="store">43.17614,-90.57341</field>
        <field name="cat">XXX</field>
       </doc></add>
      

      <add>
      <doc>
        <field name="id">SOLR1000</field>
        <field name="name">Solr, the Enterprise Search Server</field>
        <field name="manu">Apache Software Foundation</field>
        <field name="cat">software</field>
        <field name="cat">search</field>
        <field name="cat">XXX</field>
        <field name="features">Advanced Full-Text Search Capabilities using Lucene</field>
        <field name="features">Optimized for High Volume Web Traffic</field>
        <field name="features">Standards Based Open Interfaces - XML and HTTP</field>
        <field name="features">Comprehensive HTML Administration Interfaces</field>
        <field name="features">Scalability - Efficient Replication to other Solr Search Servers</field>
        <field name="features">Flexible and Adaptable with XML configuration and Schema</field>
        <field name="features">Good unicode support: h&#xE9;llo (hello with an accent over the e)</field>
        <field name="price">0</field>
        <field name="popularity">10</field>
        <field name="inStock">true</field>
        <field name="incubationdate_dt">2006-01-17T00:00:00.000Z</field>
      </doc>
      </add>
      

1 个答案:

答案 0 :(得分:1)

如果您不提供该值,则会将其视为默认值。与第四次查询一样

q=price means it searches the default searchable field having value "price" 

这就是为什么你得到0结果,因为没有价格是0值。