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 "Kashyap, Raghu" <Ra...@orbitz.com> on 2008/09/04 21:42:36 UTC
Question about Data Types
Hi,
I have a use case where I need to define my own datatype (Money).
Will something like this work? Are there any issues with this approach?
Schema.xml
<fieldType name="money" class="xyz.Money" omitNorms="true" />
Thanks,
Raghu
Ps: We are using the trunk version of solr
RE: Question about Data Types
Posted by "Kashyap, Raghu" <Ra...@orbitz.com>.
Thanks for your response Hoss.
Yes we do have Money class already implemented in other areas of our
application which I would like to use.
I will try this out.
-Raghu
-----Original Message-----
From: Chris Hostetter [mailto:hossman_lucene@fucit.org]
Sent: Friday, September 05, 2008 12:20 AM
To: solr-user@lucene.apache.org
Subject: Re: Question about Data Types
: I have a use case where I need to define my own datatype (Money).
: Will something like this work? Are there any issues with this
approach?
: <fieldType name="money" class="xyz.Money" omitNorms="true" />
Assuming you have implemented a Java class named "Money" in the package
"xyz" and you are subclassing the FieldType class -- then yes. you can
implment any sort of FieldType you want. YOu can even subclass
something
like the SortableFloatType to reuse a lot of the existing code if it's
useful to you.
But i'm not sure if that's what you are asking.
You could also do something like this...
<fieldType name="money" class="solr.SortableFloat" />
now you've got a fieldType called "money" that you can refer to in other
fields in your schema, and you don't have to writ any java code --
assuming all you really care about is storing a floating point value.
It really depends on what it is you mean by saying you want your own
datatype.
-Hoss
Re: Question about Data Types
Posted by Chris Hostetter <ho...@fucit.org>.
: I have a use case where I need to define my own datatype (Money).
: Will something like this work? Are there any issues with this approach?
: <fieldType name="money" class="xyz.Money" omitNorms="true" />
Assuming you have implemented a Java class named "Money" in the package
"xyz" and you are subclassing the FieldType class -- then yes. you can
implment any sort of FieldType you want. YOu can even subclass something
like the SortableFloatType to reuse a lot of the existing code if it's
useful to you.
But i'm not sure if that's what you are asking.
You could also do something like this...
<fieldType name="money" class="solr.SortableFloat" />
now you've got a fieldType called "money" that you can refer to in other
fields in your schema, and you don't have to writ any java code --
assuming all you really care about is storing a floating point value.
It really depends on what it is you mean by saying you want your own
datatype.
-Hoss