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 Anurag Sharma <an...@gmail.com> on 2014/09/27 10:05:31 UTC

applicability of schema on document

I am trying to understand how the schema and it's field types gets applied
to a document. Is it based on a document Id e.g. how to specify solr to
store fields like age as integer, dateofbirth as date but not as a string
or vice versa. Also, is it possible to change the field type at runtime?

Direct update using below command adds the values even when the id doesn't
exist:
curl http://localhost:8983/solr/update\?commit\=true -H
'Content-type:application/json' -d '[{"dob": {"add":
["2014-02-12T12:00:00Z", "2014-07-16T12:00:00Z"]}, "id": 1111}]'
My doubts in the above scenario are:

   - Is it taking some default types based on parsed values?
   - Is it also possible to store multiple types in a single field?
   - What are the rules for schema less doc

Above scenario is tried using solr.war in example/webapps Following are
multiple schema files in example directory
./example/example-DIH/solr/db/conf/schema.xml
./example/example-DIH/solr/mail/conf/schema.xml
./example/example-DIH/solr/rss/conf/schema.xml
./example/example-DIH/solr/solr/conf/schema.xml
./example/example-DIH/solr/tika/conf/schema.xml
./example/example-schemaless/solr/collection1/conf/schema.xml
./example/multicore/core0/conf/schema.xml
./example/multicore/core1/conf/schema.xml
./example/solr/collection1/conf/schema.xml


Any documentation or unit tests describing the flow, creating and using the
schema will be helpful.

Thanks
Anurag

Re: applicability of schema on document

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
Anurag,

Just answering your three emails on two emailing lists. You seem to
want to jump into the middle of Solr and then dig your way both ways.
So, your question here is a mix of very basic and unnecessarily
complicated.

Specifically, you seem to be missing a link between schema.xml and
solrconfig.xml. You need to look at both of the files if you are
actually trying to understand what's going on, as opposed to just
changing one thing to get from one point to another.

Both files for multiple examples that come with Solr are heavily
documented and give you MORE than you want to know. In fact, half of
the solrconfig.xml is a bit scary to me right now and I wrote a book
on Solr. But it has the answers and if you just read it, you will know
better questions to ask.

Regards,
    Alex.
P.s. Feel free to ignore this, we'll help you anyway. It's just that
the above might be MORE efficient than the strategy you selected so
far.
Personal: http://www.outerthoughts.com/ and @arafalov
Solr resources and newsletter: http://www.solr-start.com/ and @solrstart
Solr popularizers community: https://www.linkedin.com/groups?gid=6713853


On 27 September 2014 04:05, Anurag Sharma <an...@gmail.com> wrote:
> I am trying to understand how the schema and it's field types gets applied
> to a document. Is it based on a document Id e.g. how to specify solr to
> store fields like age as integer, dateofbirth as date but not as a string
> or vice versa. Also, is it possible to change the field type at runtime?
>
> Direct update using below command adds the values even when the id doesn't
> exist:
> curl http://localhost:8983/solr/update\?commit\=true -H
> 'Content-type:application/json' -d '[{"dob": {"add":
> ["2014-02-12T12:00:00Z", "2014-07-16T12:00:00Z"]}, "id": 1111}]'
> My doubts in the above scenario are:
>
>    - Is it taking some default types based on parsed values?
>    - Is it also possible to store multiple types in a single field?
>    - What are the rules for schema less doc
>
> Above scenario is tried using solr.war in example/webapps Following are
> multiple schema files in example directory
> ./example/example-DIH/solr/db/conf/schema.xml
> ./example/example-DIH/solr/mail/conf/schema.xml
> ./example/example-DIH/solr/rss/conf/schema.xml
> ./example/example-DIH/solr/solr/conf/schema.xml
> ./example/example-DIH/solr/tika/conf/schema.xml
> ./example/example-schemaless/solr/collection1/conf/schema.xml
> ./example/multicore/core0/conf/schema.xml
> ./example/multicore/core1/conf/schema.xml
> ./example/solr/collection1/conf/schema.xml
>
>
> Any documentation or unit tests describing the flow, creating and using the
> schema will be helpful.
>
> Thanks
> Anurag