You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Preetam Dwivedi (JIRA)" <ji...@apache.org> on 2015/08/06 22:56:06 UTC

[jira] [Commented] (SOLR-1945) Add support for child docs in DocumentObjectBinder

    [ https://issues.apache.org/jira/browse/SOLR-1945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14660778#comment-14660778 ] 

Preetam Dwivedi commented on SOLR-1945:
---------------------------------------

I am getting following error when I am using @Field(child=true)

{code:xml}
Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr: undefined field: "child"
	at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:560)
	at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:235)
	at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:227)
	at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:135)
	at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:174)
	at org.apache.solr.client.solrj.SolrClient.addBean(SolrClient.java:278)
	at com.portal.job.services.solr.TestSolrService.test(TestSolrService.java:27)
	at com.portal.job.services.solr.TestSolrService.main(TestSolrService.java:14)

{code}
Code:

{code:java}
import java.io.IOException;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.beans.Field;
import org.apache.solr.client.solrj.impl.HttpSolrClient;

public class TestSolrService {

	public static void main(String[] args) throws IOException,
			SolrServerException {
		new TestSolrService().test();
	}

	public void test() throws IOException, SolrServerException {

		SolrClient client = new HttpSolrClient("http://localhost:8983/solr/");

		Test test = new Test();
		test.setId("2");
		Child c = new Child();
		c.child = true;
		c.id = "1";
		test.setChild(c);
		client.addBean("test", test, 10);

		client.close();

	}

	public class Child {
		@Field
		public String id;
		@Field
		public boolean child;
	}

	public class Test {

		@Field
		private String id;

		@Field(child = true)
		private Child child;

		public String getId() {
			return id;
		}

		public void setId(String id) {
			this.id = id;
		}

		public Child getChild() {
			return child;
		}

		public void setChild(Child child) {
			this.child = child;
		}

	}
}
{code}

> Add support for child docs in DocumentObjectBinder
> --------------------------------------------------
>
>                 Key: SOLR-1945
>                 URL: https://issues.apache.org/jira/browse/SOLR-1945
>             Project: Solr
>          Issue Type: Improvement
>            Reporter: Mark Miller
>            Assignee: Noble Paul
>            Priority: Minor
>             Fix For: 5.1, Trunk
>
>         Attachments: SOLR-1945.patch, SOLR-1945.patch
>
>
> see http://search.lucidimagination.com/search/document/d909d909420aeb4e/does_solrj_support_nested_annotated_beans
> Would be nice to be able to pass an object graph to solrj with @field annotations rather than just a top level class



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org