简体   繁体   English

如何从Solr索引读取?

[英]How to read from solr index?

I index my db table directly into solr according to this documentation http://wiki.apache.org/solr/DIHQuickStart 我根据此文档http://wiki.apache.org/solr/DIHQuickStart将数据库表直接索引到solr中

The full import works. 完整的导入作品。 However when I query data like this I get no result 但是,当我查询这样的数据时,我没有结果

   $solr = new Apache_Solr_Service('localhost', '8983', 'solr/');

   $offset = 0;
   $limit = 1000;

   $queries = array(
      'details:Server'
   );

   $response = $solr->search( $query, $offset, $limit );

Solr itself is running. Solr本身正在运行。 I try to query the row "details" but it gives me now result. 我尝试查询“详细信息”行,但现在得到了结果。

Any idea what I am doing wrong? 知道我在做什么错吗?

Schema.xml : http://pastebin.com/2kx7MkDX Schema.xml: http//pastebin.com/2kx7MkDX

data-config.xml : http://pastebin.com/vtDZzuqC data-config.xml: http//pastebin.com/vtDZzuqC

solrconfig.xml : http://pastebin.com/V6nzvMa5 solrconfig.xml: http//pastebin.com/V6nzvMa5

all from /example/solr/conf/ 全部来自/ example / solr / conf /

Here's your answer: 这是您的答案:

Your 'details' field is defined as 'string'. 您的“详细信息”字段定义为“字符串”。 In Solr, it means it's indexed as a single literal token. 在Solr中,这意味着它被索引为单个文字标记。 The 'string' type is usually used for identifiers. “字符串”类型通常用于标识符。

Therefore, your query 'details:Server' would ONLY match the documents where 'details' exactly equals 'Server', and NOT the document where 'details' contains 'Server'. 因此,您的查询“的详细信息:服务器”将匹配其中“细节” 恰好等于“服务器”的文件,并且而不在“细节”包含“服务器”文档。

Change your 'details' field to something that will index your text as separate words (tokens): 将“详细信息”字段更改为将您的文本编入单独的单词(标记)的内容:

<field name="details" type="text" ...
<!-- for instance -->

And re-index everything. 并重新索引所有内容。 You might also want to review your other fields definitions. 您可能还需要查看其他字段定义。

I encourage you to read the default type definitions in your schema.xml. 我鼓励您阅读schema.xml中的默认类型定义。

Should 应该

$solr = new Apache_Solr_Service('localhost', '8983', 'solr/');

be

$solr = new Apache_Solr_Service('localhost', '8983', '/solr');

add to data-config.xml 添加到data-config.xml

<dataConfig>
  <dataSource type="JdbcDataSource"
             driver="com.mysql.jdbc.Driver"
             url="jdbc:mysql://localhost/admin_pproject"
             user="root"
             password=""/>
  <document>
    <entity name="id"
           query="select id, name,details, owner, subtype, edit, sub, type, provision, active from programme">

           <!-- ADD-->         
           <field column="id" name="id"/>
           <field column="name" name="name" />
           <field column="details" name="details" />
           <field column="owner" name="owner" />
           <field column="subtype" name="subtype" />
           <field column="edit" name="edit" />
           <field column="sub" name="sub" />
           <field column="type" name="type" />
           <field column="provision" name="provision" />
           <field column="active" name="active" />


        </entity>
  </document>
</dataConfig>

test 测试

We probably need to see your schema.xml. 我们可能需要查看您的schema.xml。 There may be an error there in it. 那里可能有错误。

What happens if you search for "server" with a lower case "s"? 如果搜索带有小写字母“ s”的“服务器”会怎样?

If that fixes it, you have an analysis problem, look in schema.xml. 如果可以解决,则您有分析问题,请查看schema.xml。

You can also look in the schema browser (follow the link on the admin page). 您也可以在模式浏览器中查找(按照管理页面上的链接)。 Click to the "details" field (on the left), and look at the 1000 or 10000 terms, and see if you see the word "server" (or "Server"). 单击“详细信息”字段(在左侧),并查看1000或10000个术语,然后查看是否看到单词“服务器”(或“服务器”)。 What you see will tell you if the word is in the index (at least, if you have less than 10,000 unique words in the field). 您所看到的内容将告诉您单词是否在索引中(至少,如果该字段中的唯一单词少于10,000个)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM