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 Silvia Suárez <ss...@anpro21.com> on 2014/04/01 18:29:02 UTC
How to add a map of key/value pairs into a solr schema?
Dear all,
I'm trying to add a map of key/value pairs into the solr schema, and I just
wordering if it is possible.
For instance:
This is my schema.xml :
<field name="c_noticia" type="string" indexed="true" stored="true"
required="true" multiValued="false" />
<field name="c_tipo" type="int" indexed="true" stored="true"
multiValued="false"/>
<field name="c_perfil" type="int" indexed="true" stored="true"
multiValued="true"/>
<field name="tipo_red" type="int" indexed="true" stored="true"
multiValued="false"/>
<field name="descriptores" type="map?" indexed="true" stored="true"
multiValued="true" />
Is it possible to define a type= map (see the example above in the schema)
into the solr xchema?, for example something like this:
map: 2252 / 23
3789 / 12
3790 / 21
3794 / 19
And get a result like this:
<doc>
<str name="c_noticia">62906367</str>
<arr name="c_perfil">
<int>2252</int>
<int>3789</int>
<int>3790</int>
<int>3794</int>
</arr>
:
:
<map? name="descriptores">
<?>2252 / 23</?>
<?>3789 / 54</?>
<?>3790 / 21</?>
<?>3794 / 12</?>
</map?>
</doc>
I mean, is it possible introduce a map into one document?
Thanks in advance for some help,
Silvia.
Re: How to add a map of key/value pairs into a solr schema?
Posted by Silvia Suárez <ss...@anpro21.com>.
Dear Jack
I'm using SolrJ to access and query the values in the solr collection,
For example,
I have a collection in solr in which I are updating the c_perfil
multivalued field, using this code:
SolrInputDocument sdoc = new SolrInputDocument();
sdoc.addField("c_noticia",doc.getFieldValue("c_noticia").toString());
Map<String,Object> fieldModifier = new HashMap<String,Object>(1);
fieldModifier.put("add",perfil);
sdoc.addField("c_perfil", fieldModifier); // add the map as the field value
server3.add( sdoc ); // send it to the solr server
server3.commit();
The result is:
<arr name="c_perfil">
<int>2252</int>
<int>3789</int>
<int>3790</int>
<int>3794</int>
</arr>
And it is working ok,
In this sense, Is it possible to update another field type, like a map
(key/value) using SolrJ?:
For example some thing like this:
<map? name="descriptores">
<?>2252 / 23</?>
<?>3789 / 54</?>
<?>3790 / 21</?>
<?>3794 / 12</?>
</map?>
Thanks a lot in advance,
Silvia.
Silvia Suárez Barón
I+D+I
<http://www.anpro21.com/>
972 989 470 / ssb@anpro21.com / <http://www.anpro21.com/twitter>
<http://www.anpro21.com/facebook>
<http://www.linkedin.com/pub/silvia-a-su%C3%A1rez-bar%C3%B3n-phd/10/b30/26a>
<http://blog.anpro21.com/>
*Tecnologías y SaaS para el análisis de marcas comerciales.*
Nota:
Usted ha recibido este mensaje al estar en la libreta de direcciones del
remitente, en los archivos de la empresa o mediante el sistema de
"responder" al ser usted la persona que contactó por este medio con el
remitente. En caso de no querer recibir ningún email mas del remitente o de
cualquier miembro de la organización a la que pertenece, por favor,
responda a este email solicitando la baja de su dirección en nuestros
archivos.
Advertencia legal:
Este mensaje y, en su caso, los ficheros anexos son confidenciales,
especialmente en lo que respecta a los datos personales, y se dirigen
exclusivamente al destinatario referenciado. Si usted no lo es y lo ha
recibido por error o tiene conocimiento del mismo por cualquier motivo, le
rogamos que nos lo comunique por este medio y proceda a destruirlo o
borrarlo, y que en todo caso se abstenga de utilizar, reproducir, alterar,
archivar o comunicar a terceros el presente mensaje y ficheros anexos, todo
ello bajo pena de incurrir en responsabilidades legales.
2014-04-01 18:35 GMT+02:00 Jack Krupansky <ja...@basetechnology.com>:
> Not directly. The various workarounds depend on how you intend to access
> and query the values. What are your use cases?
>
> -- Jack Krupansky
>
> -----Original Message----- From: Silvia Suárez
> Sent: Tuesday, April 1, 2014 12:29 PM
> To: solr-user@lucene.apache.org
> Subject: How to add a map of key/value pairs into a solr schema?
>
> Dear all,
>
> I'm trying to add a map of key/value pairs into the solr schema, and I just
> wordering if it is possible.
>
> For instance:
>
> This is my schema.xml :
>
> <field name="c_noticia" type="string" indexed="true" stored="true"
> required="true" multiValued="false" />
> <field name="c_tipo" type="int" indexed="true" stored="true"
> multiValued="false"/>
> <field name="c_perfil" type="int" indexed="true" stored="true"
> multiValued="true"/>
> <field name="tipo_red" type="int" indexed="true" stored="true"
> multiValued="false"/>
> <field name="descriptores" type="map?" indexed="true" stored="true"
> multiValued="true" />
>
>
> Is it possible to define a type= map (see the example above in the schema)
> into the solr xchema?, for example something like this:
>
> map: 2252 / 23
> 3789 / 12
> 3790 / 21
> 3794 / 19
>
> And get a result like this:
>
> <doc>
> <str name="c_noticia">62906367</str>
> <arr name="c_perfil">
> <int>2252</int>
> <int>3789</int>
> <int>3790</int>
> <int>3794</int>
> </arr>
> :
> :
> <map? name="descriptores">
> <?>2252 / 23</?>
> <?>3789 / 54</?>
> <?>3790 / 21</?>
> <?>3794 / 12</?>
> </map?>
> </doc>
>
> I mean, is it possible introduce a map into one document?
>
> Thanks in advance for some help,
>
> Silvia.
>
Re: How to add a map of key/value pairs into a solr schema?
Posted by Jack Krupansky <ja...@basetechnology.com>.
Not directly. The various workarounds depend on how you intend to access and
query the values. What are your use cases?
-- Jack Krupansky
-----Original Message-----
From: Silvia Suárez
Sent: Tuesday, April 1, 2014 12:29 PM
To: solr-user@lucene.apache.org
Subject: How to add a map of key/value pairs into a solr schema?
Dear all,
I'm trying to add a map of key/value pairs into the solr schema, and I just
wordering if it is possible.
For instance:
This is my schema.xml :
<field name="c_noticia" type="string" indexed="true" stored="true"
required="true" multiValued="false" />
<field name="c_tipo" type="int" indexed="true" stored="true"
multiValued="false"/>
<field name="c_perfil" type="int" indexed="true" stored="true"
multiValued="true"/>
<field name="tipo_red" type="int" indexed="true" stored="true"
multiValued="false"/>
<field name="descriptores" type="map?" indexed="true" stored="true"
multiValued="true" />
Is it possible to define a type= map (see the example above in the schema)
into the solr xchema?, for example something like this:
map: 2252 / 23
3789 / 12
3790 / 21
3794 / 19
And get a result like this:
<doc>
<str name="c_noticia">62906367</str>
<arr name="c_perfil">
<int>2252</int>
<int>3789</int>
<int>3790</int>
<int>3794</int>
</arr>
:
:
<map? name="descriptores">
<?>2252 / 23</?>
<?>3789 / 54</?>
<?>3790 / 21</?>
<?>3794 / 12</?>
</map?>
</doc>
I mean, is it possible introduce a map into one document?
Thanks in advance for some help,
Silvia.