Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query result entity have another entity's result [DATASOLR-119] #244

Open
spring-projects-issues opened this issue Sep 29, 2013 · 2 comments
Open

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Sep 29, 2013

JetsonLee opened DATASOLR-119 and commented

1、I create 2 class:DocumentEntity and KnowledgeEntity;

2、user solr db-data-config.xml like this:

<dataConfig>
	<dataSource driver="com.mysql.jdbc.Driver"
		url="jdbc:mysql://localhost:3306/my_db?useUnicode=true&amp;characterEncoding=UTF-8"
		user="root" password="root" />
	<document>
		<entity name="documentEntity" query="SELECT * FROM sys_document">
			<field column="id" name="id" type="string" indexed="true"
				stored="true" required="true" />
			<field column="title" name="title" type="string" indexed="true"
				stored="true" required="true" />
			<field column="content" name="content" type="string" indexed="true"
				stored="true" required="true" />
		</entity>

		<entity name="knowledgeEntity" query="SELECT * FROM sys_knowledge">
			<field column="id" name="id" type="string" indexed="true"
				stored="true" required="true" />
			<field column="title" name="title" type="string" indexed="true"
				stored="true" required="true" />
			<field column="keyword" name="keyword" type="string" indexed="true"
				stored="true" required="true" />
			<field column="publish_date" name="publishDate" type="date"
				indexed="true" stored="true" required="true" />
			<field column="content" name="content" type="string" indexed="true"
				stored="true" required="true" />
		</entity>
	</document>
</dataConfig>

3、user solr import all data like this:
http://localhost:8080/solr/dataimport?command=full-import

4、query in solr like this:
http://localhost:8080/solr/select?q=title:*Tom*

the result list contains DocumentEntity and KnowledgeEntity data;

5、use Spring Data Solr to query KnowledgeEntity like this:

@Highlight(fields = { "name", "keyword", "contents" })
	public HighlightPage<KnowledgeEntity> searchByKeyword(HighlightQuery query) {

		SolrOperations so = getSolrOperations();

		return so.queryForHighlightPage(query, KnowledgeEntity.class);
	}

the result list's entity is KnowledgeEntity, but also contains DocumentEntity and KnowledgeEntity data;

I hope it can be resolved quickly!Because it affect system's availability.

Thank you!


Affects: 1.0 M1

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 30, 2013

Christoph Strobl commented

Hi,
as far as I can tell you seem to add two differnt types of Enitites to one single index.
Providing KnowledgeEntity.class along with the query metod will take care of converting result documents into the desired type, but does not enhance the query itself.
I assume what you need would be an additional field within your schema eg. class.type on which you perform a filter query.

query.addFilterQuery(new SimpleFilterQuery(new Critiera("class.type").is("KnowledgeEntity")));
@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 1, 2013

JetsonLee commented

It can be work.... ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants