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 blargy <zm...@hotmail.com> on 2010/03/12 07:58:15 UTC

DIH field options

How can you simply add a static value like? <field name="id" value="123"/>
How does one add a static multi-value field? <field name="category_ids"
values="123, 456"/>

Is there any documentation on all the options for the field tag in
data-config.xml?

Thanks for the help
-- 
View this message in context: http://old.nabble.com/DIH-field-options-tp27873996p27873996.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: DIH field options

Posted by Gregg Hoshovsky <ho...@ohsu.edu>.
You can use mysql , select *, “staticdata” as staticdata from table x.
As long as your  field name is staticdata, this should add it there.


On 3/12/10 8:39 AM, "Tommy Chheng" <to...@gmail.com> wrote:

 Haven't tried this myself but try adding a default value  and don't
specify it during the import.
http://wiki.apache.org/solr/SchemaXml


On 3/12/10 7:56 AM, blargy wrote:
> Forgive me but I'm slightly retarded... I grew up underneath some power lines
> ;)
>
> I've read through that wiki but I still can't find what I'm looking for. I
> just want to give one of the DIH entities/fields a static value (ie it
> doesnt come from a database column). How can I configure this?
>
> FYI this is data-config.xml not schema.xml.
>
>    <document>
>      <entity name="item" query="select * from items">
>        <field name="my_field"  column="static_value_not_from_db"/>
>        ....
>      </entity>
>    </document>
>
>
>
>
> Tommy Chheng-4 wrote:
>>    The wiki page has most of the info you need
>> *http://wiki*.apache.org/*solr*/DataImportHandler
>>
>> To use multi-value fields, your schema.xml must define it with
>> multiValued="true"
>>
>>
>> On 3/11/10 10:58 PM, blargy wrote:
>>> How can you simply add a static value like?<field name="id"
>>> value="123"/>
>>> How does one add a static multi-value field?<field name="category_ids"
>>> values="123, 456"/>
>>>
>>> Is there any documentation on all the options for the field tag in
>>> data-config.xml?
>>>
>>> Thanks for the help
>> --
>> Tommy Chheng
>> Programmer and UC Irvine Graduate Student
>> Twitter @tommychheng
>> http://tommy.chheng.com
>>
>>
>>

--
Tommy Chheng
Programmer and UC Irvine Graduate Student
Twitter @tommychheng
http://tommy.chheng.com



Re: DIH field options

Posted by Tommy Chheng <to...@gmail.com>.
  Haven't tried this myself but try adding a default value  and don't 
specify it during the import.
http://wiki.apache.org/solr/SchemaXml


On 3/12/10 7:56 AM, blargy wrote:
> Forgive me but I'm slightly retarded... I grew up underneath some power lines
> ;)
>
> I've read through that wiki but I still can't find what I'm looking for. I
> just want to give one of the DIH entities/fields a static value (ie it
> doesnt come from a database column). How can I configure this?
>
> FYI this is data-config.xml not schema.xml.
>
>    <document>
>      <entity name="item" query="select * from items">
>        <field name="my_field"  column="static_value_not_from_db"/>
>        ....
>      </entity>
>    </document>
>
>
>
>
> Tommy Chheng-4 wrote:
>>    The wiki page has most of the info you need
>> *http://wiki*.apache.org/*solr*/DataImportHandler
>>
>> To use multi-value fields, your schema.xml must define it with
>> multiValued="true"
>>
>>
>> On 3/11/10 10:58 PM, blargy wrote:
>>> How can you simply add a static value like?<field name="id"
>>> value="123"/>
>>> How does one add a static multi-value field?<field name="category_ids"
>>> values="123, 456"/>
>>>
>>> Is there any documentation on all the options for the field tag in
>>> data-config.xml?
>>>
>>> Thanks for the help
>> -- 
>> Tommy Chheng
>> Programmer and UC Irvine Graduate Student
>> Twitter @tommychheng
>> http://tommy.chheng.com
>>
>>
>>

-- 
Tommy Chheng
Programmer and UC Irvine Graduate Student
Twitter @tommychheng
http://tommy.chheng.com


Re: DIH field options

Posted by blargy <zm...@hotmail.com>.
Im still having a problem with this... for example I would assume this would
index the value Item into the field called type 

  <document>
    <entity name="item" 
        transformer="TemplateTransformer"
        query="select * from items">
      <field name="type"  template="Item"/>
    </entity>
  </document>


However I receive this error when starting up Solr: Caused by:
org.apache.solr.handler.dataimport.DataImportHandlerException: Field must
have a column attribute

I must not be getting something. Did I mentioned I was booted in the head by
a horse when I was young?

Ok, even if I have the template transformer working to set static values
will this work for multi-valued fields?

Thanks yet again



Ahmet Arslan wrote:
> 
>> I feel like the default option is a little hacky plus I'll
>> probably be
>> sharing my schema.xml for multiple cores using dynamic
>> field types.
>> 
>> I can't believe there isnt an easy way to specify this. So
>> my only options
>> is something like this?
> 
> Also you can generate this static value from your SQL sentence. Something
> like:  select *, 'static_value_not_from_db' as my_field from items
>  
>> What if I don't need a template transformer for all the
>> other fields? Is it
>> ok to mix and match? Will this effect performance at all? 
> 
> Template Transformer is activated with template="". All Transformers work
> like that. I don't think that it will noticeably effect performance.
> 
> 
>       
> 
> 

-- 
View this message in context: http://old.nabble.com/DIH-field-options-tp27873996p27881023.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: DIH field options

Posted by Ahmet Arslan <io...@yahoo.com>.
> I feel like the default option is a little hacky plus I'll
> probably be
> sharing my schema.xml for multiple cores using dynamic
> field types.
> 
> I can't believe there isnt an easy way to specify this. So
> my only options
> is something like this?

Also you can generate this static value from your SQL sentence. Something like:  select *, 'static_value_not_from_db' as my_field from items
 
> What if I don't need a template transformer for all the
> other fields? Is it
> ok to mix and match? Will this effect performance at all? 

Template Transformer is activated with template="". All Transformers work like that. I don't think that it will noticeably effect performance.


      

Re: DIH field options

Posted by blargy <zm...@hotmail.com>.
I feel like the default option is a little hacky plus I'll probably be
sharing my schema.xml for multiple cores using dynamic field types.

I can't believe there isnt an easy way to specify this. So my only options
is something like this?

<document>
  <entity name="item"
          transformer="TemplateTransformer"
          query="select * from items">
       <field name="my_field"  template="static_value_not_from_db"/>
       ....
  </entity>
</document>

What if I don't need a template transformer for all the other fields? Is it
ok to mix and match? Will this effect performance at all? 

Thanks again!



Ahmet Arslan wrote:
> 
>> Forgive me but I'm slightly retarded... I grew up
>> underneath some power lines
>> ;)
>> 
>> I've read through that wiki but I still can't find what I'm
>> looking for. I
>> just want to give one of the DIH entities/fields a static
>> value (ie it
>> doesnt come from a database column). How can I configure
>> this?
>> 
>> FYI this is data-config.xml not schema.xml.
>> 
>>   <document>
>>     <entity name="item" query="select * from
>> items">
>>       <field name="my_field" 
>> column="static_value_not_from_db"/>
>>       ....
>>     </entity>
>>   </document>
>> 
> 
> I didn't do it by-myself but i think it can be done with
> TemplateTransformer[1] with something like:
> 
> <field column="my_field" template="static_value_not_from_db" />
> 
> Alternatively you can define default value of a field in schema.xml:
> 
> <field name="timestamp" type="date" indexed="true" stored="true"
> default="NOW" multiValued="false"/>
> 
> [1] http://wiki.apache.org/solr/DataImportHandler#TemplateTransformer
> 
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/DIH-field-options-tp27873996p27880065.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: DIH field options

Posted by Ahmet Arslan <io...@yahoo.com>.
> Forgive me but I'm slightly retarded... I grew up
> underneath some power lines
> ;)
> 
> I've read through that wiki but I still can't find what I'm
> looking for. I
> just want to give one of the DIH entities/fields a static
> value (ie it
> doesnt come from a database column). How can I configure
> this?
> 
> FYI this is data-config.xml not schema.xml.
> 
>   <document>
>     <entity name="item" query="select * from
> items">
>       <field name="my_field" 
> column="static_value_not_from_db"/>
>       ....
>     </entity>
>   </document>
> 

I didn't do it by-myself but i think it can be done with TemplateTransformer[1] with something like:

<field column="my_field" template="static_value_not_from_db" />

Alternatively you can define default value of a field in schema.xml:

<field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>

[1] http://wiki.apache.org/solr/DataImportHandler#TemplateTransformer


      

Re: DIH field options

Posted by blargy <zm...@hotmail.com>.
Forgive me but I'm slightly retarded... I grew up underneath some power lines
;)

I've read through that wiki but I still can't find what I'm looking for. I
just want to give one of the DIH entities/fields a static value (ie it
doesnt come from a database column). How can I configure this?

FYI this is data-config.xml not schema.xml.

  <document>
    <entity name="item" query="select * from items">
      <field name="my_field"  column="static_value_not_from_db"/>
      ....
    </entity>
  </document>




Tommy Chheng-4 wrote:
> 
>   The wiki page has most of the info you need
> *http://wiki*.apache.org/*solr*/DataImportHandler
> 
> To use multi-value fields, your schema.xml must define it with 
> multiValued="true"
> 
> 
> On 3/11/10 10:58 PM, blargy wrote:
>> How can you simply add a static value like?<field name="id"
>> value="123"/>
>> How does one add a static multi-value field?<field name="category_ids"
>> values="123, 456"/>
>>
>> Is there any documentation on all the options for the field tag in
>> data-config.xml?
>>
>> Thanks for the help
> 
> -- 
> Tommy Chheng
> Programmer and UC Irvine Graduate Student
> Twitter @tommychheng
> http://tommy.chheng.com
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/DIH-field-options-tp27873996p27878836.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: DIH field options

Posted by Tommy Chheng <to...@gmail.com>.
  The wiki page has most of the info you need
*http://wiki*.apache.org/*solr*/DataImportHandler

To use multi-value fields, your schema.xml must define it with 
multiValued="true"


On 3/11/10 10:58 PM, blargy wrote:
> How can you simply add a static value like?<field name="id" value="123"/>
> How does one add a static multi-value field?<field name="category_ids"
> values="123, 456"/>
>
> Is there any documentation on all the options for the field tag in
> data-config.xml?
>
> Thanks for the help

-- 
Tommy Chheng
Programmer and UC Irvine Graduate Student
Twitter @tommychheng
http://tommy.chheng.com


Re: DIH field options

Posted by Dennis Gearon <ge...@sbcglobal.net>.
I asked, but did not see a reply to the following question, (for a newbie like me):

Question: 
  What does DIH mean?
Answer:
  Data Import Handler

Sent to list to aid searches by other newbies in the future.
Dennis Gearon

Signature Warning
----------------
EARTH has a Right To Life,
  otherwise we all die.

Read 'Hot, Flat, and Crowded'
Laugh at http://www.yert.com/film.php


--- On Thu, 3/11/10, blargy <zm...@hotmail.com> wrote:

> From: blargy <zm...@hotmail.com>
> Subject: DIH field options
> To: solr-user@lucene.apache.org
> Date: Thursday, March 11, 2010, 10:58 PM
> 
> How can you simply add a static value like? <field
> name="id" value="123"/>
> How does one add a static multi-value field? <field
> name="category_ids"
> values="123, 456"/>
> 
> Is there any documentation on all the options for the field
> tag in
> data-config.xml?
> 
> Thanks for the help
> -- 
> View this message in context: http://old.nabble.com/DIH-field-options-tp27873996p27873996.html
> Sent from the Solr - User mailing list archive at
> Nabble.com.
> 
>