You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Praveen Kumar Jayaram <Pr...@gmail.com> on 2009/04/02 13:30:19 UTC

Re: Composite POJO support

Could someone give suggestions for this issue?


Praveen Kumar Jayaram wrote:
> 
> Hi
> 
> I am trying to have a complex POJO type in Solr 1.3
> i.e Object inside object.
> 
> Below is a sample Field created,
> 
> public class TestType extends FieldType{
>     @Field
>     private String requestorID_s_i_s_nm;
>     
>     @Field
>     private String partNumber;
>     
>     @Field
>     private String requestorName_s_i_s_nm;
>     
>     @Field
>     private InnerType innerType;
> }
> 
> Where InnerType is another custom Java type.
> 
> public class InnerType extends FieldType{
> 	private String name_s_i_s_nm;
> }
> 
> 
> The schema configuration is as shown below,
> 
> ....
> <fieldType name="TestType" class="com.abc.lucene.TestType"
> sortMissingLast="true" omitNorms="true"/>
> <fieldType name="InnerType" class="com.abc.lucene.InnerType"
> sortMissingLast="true" omitNorms="true"/>
> ....
> ....
> 
> When I try to add an TestType POJO using below code, am getting unkown
> field "innerType" error,
> 
> String url = "http://localhost:8983/solr";
> SolrServer server = new CommonsHttpSolrServer( url );
> 
> InnerType inner = new InnerType();
> inner.setName_s_i_s_nm("Test");
>     		
> TestType praveen = new TestType();
> praveen.setPartNumber("000001-0001");
> praveen.setRequestorID_s_i_s_nm("1111");
> praveen.setRequestorName_s_i_s_nm("Praveen Kumar Jayaram");
> praveen.setInnerType(inner);
> 
> server.addBean(praveen);
> UpdateRequest req = new UpdateRequest();
> req.setAction( UpdateRequest.ACTION.COMMIT, false, false );
> UpdateResponse res = req.process(server);
> 
> Initially POJO was getting added when it was not composite POJO.
> After trying to have composite POJO things are not working.
> What is that I am doing wrong??
> 
> Any help will be appreciated.
> 
> 
> 


-----
Regards,
Praveen
-- 
View this message in context: http://www.nabble.com/Composite-POJO-support-tp22841854p22845799.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Composite POJO support

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>.
OK . That is not a good solution.

In Solr, you can only have a flat document structure. Where each field
is a primitive (String, Number, Date) or a List of primitives.So, the
SolrJ API only supports these . You may really not need a Custome
type.



On Mon, Apr 6, 2009 at 11:07 AM, Praveen Kumar Jayaram
<Pr...@gmail.com> wrote:
>
>
> Hi Noble,
>
> Storing fields as Strings means I have to use a POJO for this activity
> right? If so I am done.
> But according to your suggestion "Let the FieldType in Solr parse and create
> appropriate data structure".
> How am I going to do this? Am very new to Solr. So please don't mind if I
> dumb questions.
>
> Please give some sample example if possible.
>
>
>
> Noble Paul നോബിള്‍  नोब्ळ् wrote:
>>
>> On Fri, Apr 3, 2009 at 11:28 AM, Praveen Kumar Jayaram
>> <Pr...@gmail.com> wrote:
>>>
>>>
>>> Thanks for the reply Noble Paul.
>>> In my application I will be having multiple types of object and the
>>> number
>>> of properties in each object will vary.
>>> So I have made them as FieldType and defined in schema.xml also
>> The POJO is a client side Object. It is converted to xml before
>> POSTING the data to Solr. The client side code is totally agnostic of
>> the field type in Solr schema.
>>
>>
>>>
>>> How do I store  the POJO without declaring it as a FieldType?
>>> Solr needs to recognize a type right?
>>
>> What you can do is to write your field value as one String. Let the
>> FieldType in Solr parse and create appropriate data structure.
>>>
>>>
>>>
>>> Noble Paul നോബിള്‍  नोब्ळ् wrote:
>>>>
>>>> why is the POJO extending FieldType?
>>>> it does not have to.
>>>>
>>>> composite types are not supported.because Solr cannot support that.
>>>> But the field can be a List or array.
>>>>
>>>> On Thu, Apr 2, 2009 at 5:00 PM, Praveen Kumar Jayaram
>>>> <Pr...@gmail.com> wrote:
>>>>>
>>>>> Could someone give suggestions for this issue?
>>>>>
>>>>>
>>>>> Praveen Kumar Jayaram wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> I am trying to have a complex POJO type in Solr 1.3
>>>>>> i.e Object inside object.
>>>>>>
>>>>>> Below is a sample Field created,
>>>>>>
>>>>>> public class TestType extends FieldType{
>>>>>>     @Field
>>>>>>     private String requestorID_s_i_s_nm;
>>>>>>
>>>>>>     @Field
>>>>>>     private String partNumber;
>>>>>>
>>>>>>     @Field
>>>>>>     private String requestorName_s_i_s_nm;
>>>>>>
>>>>>>     @Field
>>>>>>     private InnerType innerType;
>>>>>> }
>>>>>>
>>>>>> Where InnerType is another custom Java type.
>>>>>>
>>>>>> public class InnerType extends FieldType{
>>>>>>       private String name_s_i_s_nm;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> The schema configuration is as shown below,
>>>>>>
>>>>>> ....
>>>>>> <fieldType name="TestType" class="com.abc.lucene.TestType"
>>>>>> sortMissingLast="true" omitNorms="true"/>
>>>>>> <fieldType name="InnerType" class="com.abc.lucene.InnerType"
>>>>>> sortMissingLast="true" omitNorms="true"/>
>>>>>> ....
>>>>>> ....
>>>>>>
>>>>>> When I try to add an TestType POJO using below code, am getting unkown
>>>>>> field "innerType" error,
>>>>>>
>>>>>> String url = "http://localhost:8983/solr";
>>>>>> SolrServer server = new CommonsHttpSolrServer( url );
>>>>>>
>>>>>> InnerType inner = new InnerType();
>>>>>> inner.setName_s_i_s_nm("Test");
>>>>>>
>>>>>> TestType praveen = new TestType();
>>>>>> praveen.setPartNumber("000001-0001");
>>>>>> praveen.setRequestorID_s_i_s_nm("1111");
>>>>>> praveen.setRequestorName_s_i_s_nm("Praveen Kumar Jayaram");
>>>>>> praveen.setInnerType(inner);
>>>>>>
>>>>>> server.addBean(praveen);
>>>>>> UpdateRequest req = new UpdateRequest();
>>>>>> req.setAction( UpdateRequest.ACTION.COMMIT, false, false );
>>>>>> UpdateResponse res = req.process(server);
>>>>>>
>>>>>> Initially POJO was getting added when it was not composite POJO.
>>>>>> After trying to have composite POJO things are not working.
>>>>>> What is that I am doing wrong??
>>>>>>
>>>>>> Any help will be appreciated.
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> -----
>>>>> Regards,
>>>>> Praveen
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Composite-POJO-support-tp22841854p22845799.html
>>>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> --Noble Paul
>>>>
>>>>
>>>
>>>
>>> -----
>>> Regards,
>>> Praveen
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Composite-POJO-support-tp22841854p22862433.html
>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> --Noble Paul
>>
>>
>
>
> -----
> Regards,
> Praveen
> --
> View this message in context: http://www.nabble.com/Composite-POJO-support-tp22841854p22902406.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
--Noble Paul

Re: Composite POJO support

Posted by Praveen Kumar Jayaram <Pr...@gmail.com>.

Hi Noble,

Storing fields as Strings means I have to use a POJO for this activity
right? If so I am done.
But according to your suggestion "Let the FieldType in Solr parse and create
appropriate data structure".
How am I going to do this? Am very new to Solr. So please don't mind if I
dumb questions.

Please give some sample example if possible.



Noble Paul നോബിള്‍  नोब्ळ् wrote:
> 
> On Fri, Apr 3, 2009 at 11:28 AM, Praveen Kumar Jayaram
> <Pr...@gmail.com> wrote:
>>
>>
>> Thanks for the reply Noble Paul.
>> In my application I will be having multiple types of object and the
>> number
>> of properties in each object will vary.
>> So I have made them as FieldType and defined in schema.xml also
> The POJO is a client side Object. It is converted to xml before
> POSTING the data to Solr. The client side code is totally agnostic of
> the field type in Solr schema.
> 
> 
>>
>> How do I store  the POJO without declaring it as a FieldType?
>> Solr needs to recognize a type right?
> 
> What you can do is to write your field value as one String. Let the
> FieldType in Solr parse and create appropriate data structure.
>>
>>
>>
>> Noble Paul നോബിള്‍  नोब्ळ् wrote:
>>>
>>> why is the POJO extending FieldType?
>>> it does not have to.
>>>
>>> composite types are not supported.because Solr cannot support that.
>>> But the field can be a List or array.
>>>
>>> On Thu, Apr 2, 2009 at 5:00 PM, Praveen Kumar Jayaram
>>> <Pr...@gmail.com> wrote:
>>>>
>>>> Could someone give suggestions for this issue?
>>>>
>>>>
>>>> Praveen Kumar Jayaram wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> I am trying to have a complex POJO type in Solr 1.3
>>>>> i.e Object inside object.
>>>>>
>>>>> Below is a sample Field created,
>>>>>
>>>>> public class TestType extends FieldType{
>>>>>     @Field
>>>>>     private String requestorID_s_i_s_nm;
>>>>>
>>>>>     @Field
>>>>>     private String partNumber;
>>>>>
>>>>>     @Field
>>>>>     private String requestorName_s_i_s_nm;
>>>>>
>>>>>     @Field
>>>>>     private InnerType innerType;
>>>>> }
>>>>>
>>>>> Where InnerType is another custom Java type.
>>>>>
>>>>> public class InnerType extends FieldType{
>>>>>       private String name_s_i_s_nm;
>>>>> }
>>>>>
>>>>>
>>>>> The schema configuration is as shown below,
>>>>>
>>>>> ....
>>>>> <fieldType name="TestType" class="com.abc.lucene.TestType"
>>>>> sortMissingLast="true" omitNorms="true"/>
>>>>> <fieldType name="InnerType" class="com.abc.lucene.InnerType"
>>>>> sortMissingLast="true" omitNorms="true"/>
>>>>> ....
>>>>> ....
>>>>>
>>>>> When I try to add an TestType POJO using below code, am getting unkown
>>>>> field "innerType" error,
>>>>>
>>>>> String url = "http://localhost:8983/solr";
>>>>> SolrServer server = new CommonsHttpSolrServer( url );
>>>>>
>>>>> InnerType inner = new InnerType();
>>>>> inner.setName_s_i_s_nm("Test");
>>>>>
>>>>> TestType praveen = new TestType();
>>>>> praveen.setPartNumber("000001-0001");
>>>>> praveen.setRequestorID_s_i_s_nm("1111");
>>>>> praveen.setRequestorName_s_i_s_nm("Praveen Kumar Jayaram");
>>>>> praveen.setInnerType(inner);
>>>>>
>>>>> server.addBean(praveen);
>>>>> UpdateRequest req = new UpdateRequest();
>>>>> req.setAction( UpdateRequest.ACTION.COMMIT, false, false );
>>>>> UpdateResponse res = req.process(server);
>>>>>
>>>>> Initially POJO was getting added when it was not composite POJO.
>>>>> After trying to have composite POJO things are not working.
>>>>> What is that I am doing wrong??
>>>>>
>>>>> Any help will be appreciated.
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> -----
>>>> Regards,
>>>> Praveen
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Composite-POJO-support-tp22841854p22845799.html
>>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> --Noble Paul
>>>
>>>
>>
>>
>> -----
>> Regards,
>> Praveen
>> --
>> View this message in context:
>> http://www.nabble.com/Composite-POJO-support-tp22841854p22862433.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> --Noble Paul
> 
> 


-----
Regards,
Praveen
-- 
View this message in context: http://www.nabble.com/Composite-POJO-support-tp22841854p22902406.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Composite POJO support

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>.
On Fri, Apr 3, 2009 at 11:28 AM, Praveen Kumar Jayaram
<Pr...@gmail.com> wrote:
>
>
> Thanks for the reply Noble Paul.
> In my application I will be having multiple types of object and the number
> of properties in each object will vary.
> So I have made them as FieldType and defined in schema.xml also
The POJO is a client side Object. It is converted to xml before
POSTING the data to Solr. The client side code is totally agnostic of
the field type in Solr schema.


>
> How do I store  the POJO without declaring it as a FieldType?
> Solr needs to recognize a type right?

What you can do is to write your field value as one String. Let the
FieldType in Solr parse and create appropriate data structure.
>
>
>
> Noble Paul നോബിള്‍  नोब्ळ् wrote:
>>
>> why is the POJO extending FieldType?
>> it does not have to.
>>
>> composite types are not supported.because Solr cannot support that.
>> But the field can be a List or array.
>>
>> On Thu, Apr 2, 2009 at 5:00 PM, Praveen Kumar Jayaram
>> <Pr...@gmail.com> wrote:
>>>
>>> Could someone give suggestions for this issue?
>>>
>>>
>>> Praveen Kumar Jayaram wrote:
>>>>
>>>> Hi
>>>>
>>>> I am trying to have a complex POJO type in Solr 1.3
>>>> i.e Object inside object.
>>>>
>>>> Below is a sample Field created,
>>>>
>>>> public class TestType extends FieldType{
>>>>     @Field
>>>>     private String requestorID_s_i_s_nm;
>>>>
>>>>     @Field
>>>>     private String partNumber;
>>>>
>>>>     @Field
>>>>     private String requestorName_s_i_s_nm;
>>>>
>>>>     @Field
>>>>     private InnerType innerType;
>>>> }
>>>>
>>>> Where InnerType is another custom Java type.
>>>>
>>>> public class InnerType extends FieldType{
>>>>       private String name_s_i_s_nm;
>>>> }
>>>>
>>>>
>>>> The schema configuration is as shown below,
>>>>
>>>> ....
>>>> <fieldType name="TestType" class="com.abc.lucene.TestType"
>>>> sortMissingLast="true" omitNorms="true"/>
>>>> <fieldType name="InnerType" class="com.abc.lucene.InnerType"
>>>> sortMissingLast="true" omitNorms="true"/>
>>>> ....
>>>> ....
>>>>
>>>> When I try to add an TestType POJO using below code, am getting unkown
>>>> field "innerType" error,
>>>>
>>>> String url = "http://localhost:8983/solr";
>>>> SolrServer server = new CommonsHttpSolrServer( url );
>>>>
>>>> InnerType inner = new InnerType();
>>>> inner.setName_s_i_s_nm("Test");
>>>>
>>>> TestType praveen = new TestType();
>>>> praveen.setPartNumber("000001-0001");
>>>> praveen.setRequestorID_s_i_s_nm("1111");
>>>> praveen.setRequestorName_s_i_s_nm("Praveen Kumar Jayaram");
>>>> praveen.setInnerType(inner);
>>>>
>>>> server.addBean(praveen);
>>>> UpdateRequest req = new UpdateRequest();
>>>> req.setAction( UpdateRequest.ACTION.COMMIT, false, false );
>>>> UpdateResponse res = req.process(server);
>>>>
>>>> Initially POJO was getting added when it was not composite POJO.
>>>> After trying to have composite POJO things are not working.
>>>> What is that I am doing wrong??
>>>>
>>>> Any help will be appreciated.
>>>>
>>>>
>>>>
>>>
>>>
>>> -----
>>> Regards,
>>> Praveen
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Composite-POJO-support-tp22841854p22845799.html
>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> --Noble Paul
>>
>>
>
>
> -----
> Regards,
> Praveen
> --
> View this message in context: http://www.nabble.com/Composite-POJO-support-tp22841854p22862433.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
--Noble Paul

Re: Composite POJO support

Posted by Praveen Kumar Jayaram <Pr...@gmail.com>.

Thanks for the reply Noble Paul.
In my application I will be having multiple types of object and the number
of properties in each object will vary.
So I have made them as FieldType and defined in schema.xml also

How do I store  the POJO without declaring it as a FieldType?
Solr needs to recognize a type right?



Noble Paul നോബിള്‍  नोब्ळ् wrote:
> 
> why is the POJO extending FieldType?
> it does not have to.
> 
> composite types are not supported.because Solr cannot support that.
> But the field can be a List or array.
> 
> On Thu, Apr 2, 2009 at 5:00 PM, Praveen Kumar Jayaram
> <Pr...@gmail.com> wrote:
>>
>> Could someone give suggestions for this issue?
>>
>>
>> Praveen Kumar Jayaram wrote:
>>>
>>> Hi
>>>
>>> I am trying to have a complex POJO type in Solr 1.3
>>> i.e Object inside object.
>>>
>>> Below is a sample Field created,
>>>
>>> public class TestType extends FieldType{
>>>     @Field
>>>     private String requestorID_s_i_s_nm;
>>>
>>>     @Field
>>>     private String partNumber;
>>>
>>>     @Field
>>>     private String requestorName_s_i_s_nm;
>>>
>>>     @Field
>>>     private InnerType innerType;
>>> }
>>>
>>> Where InnerType is another custom Java type.
>>>
>>> public class InnerType extends FieldType{
>>>       private String name_s_i_s_nm;
>>> }
>>>
>>>
>>> The schema configuration is as shown below,
>>>
>>> ....
>>> <fieldType name="TestType" class="com.abc.lucene.TestType"
>>> sortMissingLast="true" omitNorms="true"/>
>>> <fieldType name="InnerType" class="com.abc.lucene.InnerType"
>>> sortMissingLast="true" omitNorms="true"/>
>>> ....
>>> ....
>>>
>>> When I try to add an TestType POJO using below code, am getting unkown
>>> field "innerType" error,
>>>
>>> String url = "http://localhost:8983/solr";
>>> SolrServer server = new CommonsHttpSolrServer( url );
>>>
>>> InnerType inner = new InnerType();
>>> inner.setName_s_i_s_nm("Test");
>>>
>>> TestType praveen = new TestType();
>>> praveen.setPartNumber("000001-0001");
>>> praveen.setRequestorID_s_i_s_nm("1111");
>>> praveen.setRequestorName_s_i_s_nm("Praveen Kumar Jayaram");
>>> praveen.setInnerType(inner);
>>>
>>> server.addBean(praveen);
>>> UpdateRequest req = new UpdateRequest();
>>> req.setAction( UpdateRequest.ACTION.COMMIT, false, false );
>>> UpdateResponse res = req.process(server);
>>>
>>> Initially POJO was getting added when it was not composite POJO.
>>> After trying to have composite POJO things are not working.
>>> What is that I am doing wrong??
>>>
>>> Any help will be appreciated.
>>>
>>>
>>>
>>
>>
>> -----
>> Regards,
>> Praveen
>> --
>> View this message in context:
>> http://www.nabble.com/Composite-POJO-support-tp22841854p22845799.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> --Noble Paul
> 
> 


-----
Regards,
Praveen
-- 
View this message in context: http://www.nabble.com/Composite-POJO-support-tp22841854p22862433.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Composite POJO support

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>.
why is the POJO extending FieldType?
it does not have to.

composite types are not supported.because Solr cannot support that.
But the field can be a List or array.

On Thu, Apr 2, 2009 at 5:00 PM, Praveen Kumar Jayaram
<Pr...@gmail.com> wrote:
>
> Could someone give suggestions for this issue?
>
>
> Praveen Kumar Jayaram wrote:
>>
>> Hi
>>
>> I am trying to have a complex POJO type in Solr 1.3
>> i.e Object inside object.
>>
>> Below is a sample Field created,
>>
>> public class TestType extends FieldType{
>>     @Field
>>     private String requestorID_s_i_s_nm;
>>
>>     @Field
>>     private String partNumber;
>>
>>     @Field
>>     private String requestorName_s_i_s_nm;
>>
>>     @Field
>>     private InnerType innerType;
>> }
>>
>> Where InnerType is another custom Java type.
>>
>> public class InnerType extends FieldType{
>>       private String name_s_i_s_nm;
>> }
>>
>>
>> The schema configuration is as shown below,
>>
>> ....
>> <fieldType name="TestType" class="com.abc.lucene.TestType"
>> sortMissingLast="true" omitNorms="true"/>
>> <fieldType name="InnerType" class="com.abc.lucene.InnerType"
>> sortMissingLast="true" omitNorms="true"/>
>> ....
>> ....
>>
>> When I try to add an TestType POJO using below code, am getting unkown
>> field "innerType" error,
>>
>> String url = "http://localhost:8983/solr";
>> SolrServer server = new CommonsHttpSolrServer( url );
>>
>> InnerType inner = new InnerType();
>> inner.setName_s_i_s_nm("Test");
>>
>> TestType praveen = new TestType();
>> praveen.setPartNumber("000001-0001");
>> praveen.setRequestorID_s_i_s_nm("1111");
>> praveen.setRequestorName_s_i_s_nm("Praveen Kumar Jayaram");
>> praveen.setInnerType(inner);
>>
>> server.addBean(praveen);
>> UpdateRequest req = new UpdateRequest();
>> req.setAction( UpdateRequest.ACTION.COMMIT, false, false );
>> UpdateResponse res = req.process(server);
>>
>> Initially POJO was getting added when it was not composite POJO.
>> After trying to have composite POJO things are not working.
>> What is that I am doing wrong??
>>
>> Any help will be appreciated.
>>
>>
>>
>
>
> -----
> Regards,
> Praveen
> --
> View this message in context: http://www.nabble.com/Composite-POJO-support-tp22841854p22845799.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
--Noble Paul