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 benjelloun <an...@gmail.com> on 2014/06/18 16:31:53 UTC

add new Fields with SolrJ without changing schema.xml

Hello,

I need to add new Fields with SolrJ without changing schema.xml.
this is my code java :

HttpSolrServer server = new HttpSolrServer("http://localhost:8080/solr");
SolrInputDocument doc = new SolrInputDocument();
 doc.addField("id", id);
 doc.addField("Titre", nomdocument);

the id and Titre are already on schema.xml, but what i need to do id to add
new fields like  firstname,last name, age...

thanks for help,
Best regards,
Anass BENJELLOUN



--
View this message in context: http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: add new Fields with SolrJ without changing schema.xml

Posted by benjelloun <an...@gmail.com>.
Hello,

I will use DynamicField for some fields but some other fields need to be
created.
this is an exemple:

*Informations*

*unique ID field*

*Type*

*indexed*

*stored*

*multivalued*

*sortmissinglast*

*required*

*Iddocument*

True

long

false

True

False

True

True

so how to add this field? by default the "id" is indexed and its type is
"string"
any idea how i can do that without changing manually the shema.xml?


thanks,
 Best regards,
 Anass BENJELLOUN




2014-06-19 9:28 GMT+02:00 Alexandre Rafalovitch [via Lucene] <
ml-node+s472066n4142771h26@n3.nabble.com>:

> Use dynamic fields definitions perhaps? Just suffix the fields with
> "_s", "_i", etc. As per schema.xml.
>
> You could also use new schemaless mode, but then when they send a
> value that auto-creates a field of wrong type, it would be really hard
> to troubleshoot.
>
> Regards,
>    Alex.
> Personal website: http://www.outerthoughts.com/
> Current project: http://www.solr-start.com/ - Accelerating your Solr
> proficiency
>
>
> On Thu, Jun 19, 2014 at 2:07 PM, benjelloun <[hidden email]
> <http://user/SendEmail.jtp?type=node&node=4142771&i=0>> wrote:
>
> > Hello,
> >
> > Because i will not stay working with the actual entreprise.
> > then no one know how to change it manually if they need to add new
> fields
> > in the futur.
> > so i need to do this with java code, can you please help me with an
> exemple
> > to complete this:
> >
> >>public static void addNewField(Boolean uniqueId,String type, Boolean
> >> indexed,Boolean stored,Boolean           multivalued,Boolean
> >> sortmissinglast,Boolean required){
> >>
> >> .........................................
> >> .........................................
> >>    }
> >
> > thanks,
> > Best regards,
> > Anass BENJELLOUN
> >
> >
> >
> > 2014-06-18 18:21 GMT+02:00 Walter Underwood [via Lucene] <
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4142771&i=1>>:
> >
> >> Why can't you change schema.xml?  --wunder
> >>
> >> On Jun 18, 2014, at 8:56 AM, benjelloun <[hidden email]
> >> <http://user/SendEmail.jtp?type=node&node=4142571&i=0>> wrote:
> >>
> >> > Hello,
> >> >
> >> > this is what i want to do:
> >> >
> >> > public static void addNewField(Boolean uniqueId,String type, Boolean
> >> > indexed,Boolean stored,Boolean           multivalued,Boolean
> >> > sortmissinglast,Boolean required){
> >> >
> >> > .........................................
> >> > .........................................
> >> >    }
> >> >
> >> > any exemple please,
> >> > thanks,
> >> > Best regards,
> >> > Anass BENJELLOUN
> >> >
> >> >
> >> >
> >> >
> >>
> >>
> >>
> >> ------------------------------
> >>  If you reply to this email, your message will be added to the
> discussion
> >> below:
> >>
> >>
> http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142571.html
> >>  To unsubscribe from add new Fields with SolrJ without changing
> >> schema.xml, click here
> >> <
>
> >> .
> >> NAML
> >> <
> http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> >>
> >
> >
> >
> >
> > --
> > View this message in context:
> http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142769.html
>
> > Sent from the Solr - User mailing list archive at Nabble.com.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142771.html
>  To unsubscribe from add new Fields with SolrJ without changing
> schema.xml, click here
> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4142515&code=YW5hc3MuYm5qQGdtYWlsLmNvbXw0MTQyNTE1fC0xMDQyNjMzMDgx>
> .
> NAML
> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142777.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: add new Fields with SolrJ without changing schema.xml

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
Use dynamic fields definitions perhaps? Just suffix the fields with
"_s", "_i", etc. As per schema.xml.

You could also use new schemaless mode, but then when they send a
value that auto-creates a field of wrong type, it would be really hard
to troubleshoot.

Regards,
   Alex.
Personal website: http://www.outerthoughts.com/
Current project: http://www.solr-start.com/ - Accelerating your Solr proficiency


On Thu, Jun 19, 2014 at 2:07 PM, benjelloun <an...@gmail.com> wrote:
> Hello,
>
> Because i will not stay working with the actual entreprise.
> then no one know how to change it manually if they need to add new fields
> in the futur.
> so i need to do this with java code, can you please help me with an exemple
> to complete this:
>
>>public static void addNewField(Boolean uniqueId,String type, Boolean
>> indexed,Boolean stored,Boolean           multivalued,Boolean
>> sortmissinglast,Boolean required){
>>
>> .........................................
>> .........................................
>>    }
>
> thanks,
> Best regards,
> Anass BENJELLOUN
>
>
>
> 2014-06-18 18:21 GMT+02:00 Walter Underwood [via Lucene] <
> ml-node+s472066n4142571h26@n3.nabble.com>:
>
>> Why can't you change schema.xml?  --wunder
>>
>> On Jun 18, 2014, at 8:56 AM, benjelloun <[hidden email]
>> <http://user/SendEmail.jtp?type=node&node=4142571&i=0>> wrote:
>>
>> > Hello,
>> >
>> > this is what i want to do:
>> >
>> > public static void addNewField(Boolean uniqueId,String type, Boolean
>> > indexed,Boolean stored,Boolean           multivalued,Boolean
>> > sortmissinglast,Boolean required){
>> >
>> > .........................................
>> > .........................................
>> >    }
>> >
>> > any exemple please,
>> > thanks,
>> > Best regards,
>> > Anass BENJELLOUN
>> >
>> >
>> >
>> >
>>
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142571.html
>>  To unsubscribe from add new Fields with SolrJ without changing
>> schema.xml, click here
>> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4142515&code=YW5hc3MuYm5qQGdtYWlsLmNvbXw0MTQyNTE1fC0xMDQyNjMzMDgx>
>> .
>> NAML
>> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142769.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: add new Fields with SolrJ without changing schema.xml

Posted by benjelloun <an...@gmail.com>.
Hello,

Because i will not stay working with the actual entreprise.
then no one know how to change it manually if they need to add new fields
in the futur.
so i need to do this with java code, can you please help me with an exemple
to complete this:

>public static void addNewField(Boolean uniqueId,String type, Boolean
> indexed,Boolean stored,Boolean           multivalued,Boolean
> sortmissinglast,Boolean required){
>
> .........................................
> .........................................
>    }

thanks,
Best regards,
Anass BENJELLOUN



2014-06-18 18:21 GMT+02:00 Walter Underwood [via Lucene] <
ml-node+s472066n4142571h26@n3.nabble.com>:

> Why can't you change schema.xml?  --wunder
>
> On Jun 18, 2014, at 8:56 AM, benjelloun <[hidden email]
> <http://user/SendEmail.jtp?type=node&node=4142571&i=0>> wrote:
>
> > Hello,
> >
> > this is what i want to do:
> >
> > public static void addNewField(Boolean uniqueId,String type, Boolean
> > indexed,Boolean stored,Boolean           multivalued,Boolean
> > sortmissinglast,Boolean required){
> >
> > .........................................
> > .........................................
> >    }
> >
> > any exemple please,
> > thanks,
> > Best regards,
> > Anass BENJELLOUN
> >
> >
> >
> >
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142571.html
>  To unsubscribe from add new Fields with SolrJ without changing
> schema.xml, click here
> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4142515&code=YW5hc3MuYm5qQGdtYWlsLmNvbXw0MTQyNTE1fC0xMDQyNjMzMDgx>
> .
> NAML
> <http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142769.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: add new Fields with SolrJ without changing schema.xml

Posted by Walter Underwood <wu...@wunderwood.org>.
Why can't you change schema.xml?  --wunder

On Jun 18, 2014, at 8:56 AM, benjelloun <an...@gmail.com> wrote:

> Hello,
> 
> this is what i want to do:
> 
> public static void addNewField(Boolean uniqueId,String type, Boolean
> indexed,Boolean stored,Boolean           multivalued,Boolean
> sortmissinglast,Boolean required){ 
> 
> .........................................
> .........................................
>    }
> 
> any exemple please,
> thanks,
> Best regards,
> Anass BENJELLOUN
> 
> 
> 
> 


Re: add new Fields with SolrJ without changing schema.xml

Posted by benjelloun <an...@gmail.com>.
Hello,

this is what i want to do:

public static void addNewField(Boolean uniqueId,String type, Boolean
indexed,Boolean stored,Boolean           multivalued,Boolean
sortmissinglast,Boolean required){ 
        
.........................................
.........................................
    }

any exemple please,
thanks,
Best regards,
Anass BENJELLOUN




--
View this message in context: http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142555.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: add new Fields with SolrJ without changing schema.xml

Posted by benjelloun <an...@gmail.com>.
Hello,

i'm using this configuration on solrconfig.xml:

<schemaFactory class="ManagedIndexSchemaFactory">
         <bool name="mutable">true</bool>
         <str name="managedSchemaResourceName">managed-schema</str>
       </schemaFactory>

Can you please give me an exemple on SolrJ for adding a new field.
thanks,
best regards,
Anass BENJELLOUN



--
View this message in context: http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515p4142533.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: add new Fields with SolrJ without changing schema.xml

Posted by Erick Erickson <er...@gmail.com>.
bq: I need to add new Fields with SolrJ without changing schema.xml

You have three options:
1> change the schema.xml file. but you say you can't. Why not?
2> use dynamic fields. If you're lucky, you have the stock schema.xml
and can use them. They'll require some suffix to match the pattern
though.
3> use "managed schemas", the schemaless variant to just try to figure
it out or the managed variant and use the API to add fields before
using them.

But under any circumstance, you probably have to change your configs.

Best,
Erick

On Wed, Jun 18, 2014 at 7:31 AM, benjelloun <an...@gmail.com> wrote:
> Hello,
>
> I need to add new Fields with SolrJ without changing schema.xml.
> this is my code java :
>
> HttpSolrServer server = new HttpSolrServer("http://localhost:8080/solr");
> SolrInputDocument doc = new SolrInputDocument();
>  doc.addField("id", id);
>  doc.addField("Titre", nomdocument);
>
> the id and Titre are already on schema.xml, but what i need to do id to add
> new fields like  firstname,last name, age...
>
> thanks for help,
> Best regards,
> Anass BENJELLOUN
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/add-new-Fields-with-SolrJ-without-changing-schema-xml-tp4142515.html
> Sent from the Solr - User mailing list archive at Nabble.com.