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_J <Pr...@gmail.com> on 2009/03/10 08:54:41 UTC

Re: Creating a new field type.


Hi Tushar,

You can try this it works out well,
.....
...
<fieldType name="TestType" class="com.abc.lucene.TestType"
sortMissingLast="true" omitNorms="true"/>

and have unique key and default search fields enabled.
.....

Java code for the new custom type,

public class TestType extends FieldType{
    @Field
    private String id_s_i_s_nm;

    @Field
    private String pNumber;
    
    @Field
    private String name_s_i_s_nm;
}

TestType testType = new TestType();
// set the properties
server.addBean(testType);
UpdateRequest req = new UpdateRequest();
req.setAction( UpdateRequest.ACTION.COMMIT, false, false );
//req.add(docs);
UpdateResponse res = req.process(server);

This uploads an object to Solr!


Tushar_Gandhi wrote:
> 
> Hi,
> Is it possible to create a new field type in solr?
> If yes, can anyone tell me how to do that?
> I tried with this:-
> <fieldType name="user_name" class="solr.TextField"
> positionIncrementGap="100">
>       <analyzer type="index">
>         <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>         <!-- in this example, we will only use synonyms at query time
>         <filter class="solr.SynonymFilterFactory"
> synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
>         -->
>         <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="stopwords.txt"/>
>         <filter class="solr.WordDelimiterFilterFactory"
> generateWordParts="1" generateNumberParts="1" catenateWords="1"
> catenateNumbers="1" catenateAll="0"/>
>         <filter class="solr.LowerCaseFilterFactory"/>
>         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>       </analyzer>
>       <analyzer type="query">
>         <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>         <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> ignoreCase="true" expand="true"/>
>         <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="stopwords.txt"/>
>         <filter class="solr.WordDelimiterFilterFactory"
> generateWordParts="1" generateNumberParts="1" catenateWords="0"
> catenateNumbers="0" catenateAll="0"/>
>         <filter class="solr.LowerCaseFilterFactory"/>
>         <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>       </analyzer>
>     </fieldType>
> Is it right?
> Thanks,
> Tushar
> 

-- 
View this message in context: http://www.nabble.com/Creating-a-new-field-type.-tp21847887p22429444.html
Sent from the Solr - User mailing list archive at Nabble.com.