在两个实体之间搜索
我是 solr 新手。我创建了两个不相关的独立实体。
在db-data-config.xml中
<entity name="vtab" query="select pid as id, pname as name from ptab order by name asc">
<field column="panchayat_id" name="panchayat_id" />
<field column="name" name="name" />
</entity>
<entity name="ptab" query="select vid as id, vname as name from vtab order by name asc">
<field column="id" name="vid" />
<field column="name" name="name" />
</entity>
在scheme.xml中
<fields>
<field name="id" type="string" indexed="true" stored="true"/>
<field name="name" type="text" indexed="true" stored="true" />
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>name</defaultSearchField>
使用此配置成功创建索引。我想按名字搜索。如果我在查询中提供名称,我希望它来自找到记录的任何表。通过上述配置,我仅从 vtab 获取记录。 ptab 中没有搜索任何记录。请指导我哪里出错了。
i am new to solr. I have created two separate entities which are not interrelated.
In db-data-config.xml
<entity name="vtab" query="select pid as id, pname as name from ptab order by name asc">
<field column="panchayat_id" name="panchayat_id" />
<field column="name" name="name" />
</entity>
<entity name="ptab" query="select vid as id, vname as name from vtab order by name asc">
<field column="id" name="vid" />
<field column="name" name="name" />
</entity>
In scheme.xml
<fields>
<field name="id" type="string" indexed="true" stored="true"/>
<field name="name" type="text" indexed="true" stored="true" />
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>name</defaultSearchField>
The index is created successfully with this configuration. I want to search by name. If i provide name in query, i want it from any of the table where record is found. With above configuration, i am getting records from only vtab. No records are being searched in ptab. Please guide me where i am going wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已将 vtab 实体命名为 ptab,反之亦然。
您可以添加到名为 vtab 的实体并检查它们是否正确索引。
id 是唯一的吗?如果 id 重复,它们将相互覆盖。
理想情况下,它应该同时搜索
you have named the vtab entity as ptab and vice versa.
Can you add to the entity named vtab and check they are indexed properly.
Are the ids unique? If the ids are duplicate they would override each other.
Ideally, It should search across both
问题解决了。我已将“id”声明为主键,但该主键已被重复。我结合 id-table_name 创建了另一个字段并将其设置为主键。现在可以正常工作了。谢谢贾延德拉·帕蒂尔先生。
problem is solved. I had declared "id" as primary key, which was being duplicated. I created another field in combination with id-table_name and set it to primary key. Its working properly now. Thank you Mr. Jayendra Patil.