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 "tech.vronk" <te...@vronk.net> on 2012/10/02 15:04:16 UTC

mapping values in fields

Hi,

I try to map values from one field into other values in another field.
For example:
original_field: orig_value1
mapped_field: mapped_value1

with the help of an explicitely defined (N:1) mapping:
orig_value1 => mapped_value1
orig_value2 => mapped_value1
orig_value3 => mapped_value2

I have tried to use SynonymFilterFactory
for the mapped_field:

<fieldtype name="mapped_field" class="solr.TextField">
       <analyzer type="index">
           <tokenizer class="solr.WhitespaceTokenizerFactory"/>
           <filter class="solr.SynonymFilterFactory" 
synonyms="region-map.txt" ignoreCase="true" expand="true"/>
       </analyzer>

combined with:
<copyField src="original_field" dest="mapped_field" />


Now, a search for
  mapped_field:mapped_value1
yields results,
however in the result the mapped_value1 does not appear at all,
but instead the orig_value1 appears also in the mapped_field.

How can I achieve, that the mapped_value appears in the result as well?


thank you,

matej

Re: mapping values in fields

Posted by Otis Gospodnetic <ot...@gmail.com>.
Matej,

During/right before indexing.  What is stored is the original.
Indexing ! = storing

--
Performance Monitoring - http://sematext.com/spm
On Oct 3, 2012 6:03 AM, "tech.vronk" <te...@vronk.net> wrote:

>
> Thank you Erick, that would explain the behaviour.
>
> But it leaves me with the question:
> When are all the analyzers/filters applied
> when not during indexing?
>
> I mean, if I define a lowercase filter on a field,
> if it is not applied on the input stream before storing
> so that I have a lowercased text stored in the index,
> at what point then?
> the only other point I can think of, is on the fly, during the search,
> but that sound terribly inefficient
> (doing the transformations every time?)
>
> would be greatful if anybody can bring some light into this for me.
>
> best,
> matej
>
>
>
> Am 02.10.2012 16:58, schrieb Erick Erickson:
>
>> Ah, I get it (finally). OK, there's no good way to do what
>> you want that I know of. The problem is that the
>> stored="true" takes effect long before any transformations
>> are applied, and is always the raw input. You effectively
>> want to chain the fields together, i.e. apply the analysis
>> chain _then_ have the copyfield take effect which is not
>> supported.
>>
>> I don't know how to accomplish this off the top of my head
>> OOB, I'd guess your client would have to manage the
>> substitutions and then just index separate fields...
>>
>> Best
>> Erick
>>
>> On Tue, Oct 2, 2012 at 9:54 AM, tech.vronk <te...@vronk.net> wrote:
>>
>>> the query is:
>>>    mapped_field:mapped_value1
>>>
>>> and seems to correctly return the documents.
>>>
>>> the mapped_field has attribute stored=true
>>> and also appears in the result (even without requesting it explicitely
>>> with
>>> fl),
>>> just with the orig_value1 instead of mapped_value1
>>>
>>> matej
>>>
>>> Am 02.10.2012 15:46, schrieb Erick Erickson:
>>>
>>>  What's the query you send? I'm guessing a bit here since you
>>>> haven't included it, but try insuring two things:
>>>>
>>>> 1>  your mapped_field is has 'stored="true" '
>>>> 2> you specify (either in your request handler on on the URL)
>>>> fl=mapped_value
>>>>
>>>> Best
>>>> Erick
>>>>
>>>> On Tue, Oct 2, 2012 at 9:04 AM, tech.vronk <te...@vronk.net> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I try to map values from one field into other values in another field.
>>>>> For example:
>>>>> original_field: orig_value1
>>>>> mapped_field: mapped_value1
>>>>>
>>>>> with the help of an explicitely defined (N:1) mapping:
>>>>> orig_value1 => mapped_value1
>>>>> orig_value2 => mapped_value1
>>>>> orig_value3 => mapped_value2
>>>>>
>>>>> I have tried to use SynonymFilterFactory
>>>>> for the mapped_field:
>>>>>
>>>>> <fieldtype name="mapped_field" class="solr.TextField">
>>>>>         <analyzer type="index">
>>>>>             <tokenizer class="solr.**WhitespaceTokenizerFactory"/>
>>>>>             <filter class="solr.**SynonymFilterFactory"
>>>>> synonyms="region-map.txt" ignoreCase="true" expand="true"/>
>>>>>         </analyzer>
>>>>>
>>>>> combined with:
>>>>> <copyField src="original_field" dest="mapped_field" />
>>>>>
>>>>>
>>>>> Now, a search for
>>>>>    mapped_field:mapped_value1
>>>>> yields results,
>>>>> however in the result the mapped_value1 does not appear at all,
>>>>> but instead the orig_value1 appears also in the mapped_field.
>>>>>
>>>>> How can I achieve, that the mapped_value appears in the result as well?
>>>>>
>>>>>
>>>>> thank you,
>>>>>
>>>>> matej
>>>>>
>>>>
>>>>
>>
>

Re: mapping values in fields

Posted by "tech.vronk" <te...@vronk.net>.
Thank you Erick, that would explain the behaviour.

But it leaves me with the question:
When are all the analyzers/filters applied
when not during indexing?

I mean, if I define a lowercase filter on a field,
if it is not applied on the input stream before storing
so that I have a lowercased text stored in the index,
at what point then?
the only other point I can think of, is on the fly, during the search,
but that sound terribly inefficient
(doing the transformations every time?)

would be greatful if anybody can bring some light into this for me.

best,
matej



Am 02.10.2012 16:58, schrieb Erick Erickson:
> Ah, I get it (finally). OK, there's no good way to do what
> you want that I know of. The problem is that the
> stored="true" takes effect long before any transformations
> are applied, and is always the raw input. You effectively
> want to chain the fields together, i.e. apply the analysis
> chain _then_ have the copyfield take effect which is not
> supported.
>
> I don't know how to accomplish this off the top of my head
> OOB, I'd guess your client would have to manage the
> substitutions and then just index separate fields...
>
> Best
> Erick
>
> On Tue, Oct 2, 2012 at 9:54 AM, tech.vronk <te...@vronk.net> wrote:
>> the query is:
>>    mapped_field:mapped_value1
>>
>> and seems to correctly return the documents.
>>
>> the mapped_field has attribute stored=true
>> and also appears in the result (even without requesting it explicitely with
>> fl),
>> just with the orig_value1 instead of mapped_value1
>>
>> matej
>>
>> Am 02.10.2012 15:46, schrieb Erick Erickson:
>>
>>> What's the query you send? I'm guessing a bit here since you
>>> haven't included it, but try insuring two things:
>>>
>>> 1>  your mapped_field is has 'stored="true" '
>>> 2> you specify (either in your request handler on on the URL)
>>> fl=mapped_value
>>>
>>> Best
>>> Erick
>>>
>>> On Tue, Oct 2, 2012 at 9:04 AM, tech.vronk <te...@vronk.net> wrote:
>>>> Hi,
>>>>
>>>> I try to map values from one field into other values in another field.
>>>> For example:
>>>> original_field: orig_value1
>>>> mapped_field: mapped_value1
>>>>
>>>> with the help of an explicitely defined (N:1) mapping:
>>>> orig_value1 => mapped_value1
>>>> orig_value2 => mapped_value1
>>>> orig_value3 => mapped_value2
>>>>
>>>> I have tried to use SynonymFilterFactory
>>>> for the mapped_field:
>>>>
>>>> <fieldtype name="mapped_field" class="solr.TextField">
>>>>         <analyzer type="index">
>>>>             <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>>>>             <filter class="solr.SynonymFilterFactory"
>>>> synonyms="region-map.txt" ignoreCase="true" expand="true"/>
>>>>         </analyzer>
>>>>
>>>> combined with:
>>>> <copyField src="original_field" dest="mapped_field" />
>>>>
>>>>
>>>> Now, a search for
>>>>    mapped_field:mapped_value1
>>>> yields results,
>>>> however in the result the mapped_value1 does not appear at all,
>>>> but instead the orig_value1 appears also in the mapped_field.
>>>>
>>>> How can I achieve, that the mapped_value appears in the result as well?
>>>>
>>>>
>>>> thank you,
>>>>
>>>> matej
>>>
>


Re: mapping values in fields

Posted by Chris Hostetter <ho...@fucit.org>.
: I don't know how to accomplish this off the top of my head
: OOB, I'd guess your client would have to manage the
: substitutions and then just index separate fields...

an UpdateProcessor would proably be the best place to apply logic like 
this to completley add/replace the value of a mapped_field based on the 
contents of an orig_field.

None of the UpdateProcessors privded outof the box with Solr will do this, 
but the new StatelessScriptUpdateProcessorFactory would make it fairly 
tivial to do in javascript -- but writing in java owuld be fairly trivial 
too... hte hadest part would be the code to build up your mapped values 
from a config file.


-Hoss

Re: mapping values in fields

Posted by Erick Erickson <er...@gmail.com>.
Ah, I get it (finally). OK, there's no good way to do what
you want that I know of. The problem is that the
stored="true" takes effect long before any transformations
are applied, and is always the raw input. You effectively
want to chain the fields together, i.e. apply the analysis
chain _then_ have the copyfield take effect which is not
supported.

I don't know how to accomplish this off the top of my head
OOB, I'd guess your client would have to manage the
substitutions and then just index separate fields...

Best
Erick

On Tue, Oct 2, 2012 at 9:54 AM, tech.vronk <te...@vronk.net> wrote:
>
> the query is:
>   mapped_field:mapped_value1
>
> and seems to correctly return the documents.
>
> the mapped_field has attribute stored=true
> and also appears in the result (even without requesting it explicitely with
> fl),
> just with the orig_value1 instead of mapped_value1
>
> matej
>
> Am 02.10.2012 15:46, schrieb Erick Erickson:
>
>> What's the query you send? I'm guessing a bit here since you
>> haven't included it, but try insuring two things:
>>
>> 1>  your mapped_field is has 'stored="true" '
>> 2> you specify (either in your request handler on on the URL)
>> fl=mapped_value
>>
>> Best
>> Erick
>>
>> On Tue, Oct 2, 2012 at 9:04 AM, tech.vronk <te...@vronk.net> wrote:
>>>
>>> Hi,
>>>
>>> I try to map values from one field into other values in another field.
>>> For example:
>>> original_field: orig_value1
>>> mapped_field: mapped_value1
>>>
>>> with the help of an explicitely defined (N:1) mapping:
>>> orig_value1 => mapped_value1
>>> orig_value2 => mapped_value1
>>> orig_value3 => mapped_value2
>>>
>>> I have tried to use SynonymFilterFactory
>>> for the mapped_field:
>>>
>>> <fieldtype name="mapped_field" class="solr.TextField">
>>>        <analyzer type="index">
>>>            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>>>            <filter class="solr.SynonymFilterFactory"
>>> synonyms="region-map.txt" ignoreCase="true" expand="true"/>
>>>        </analyzer>
>>>
>>> combined with:
>>> <copyField src="original_field" dest="mapped_field" />
>>>
>>>
>>> Now, a search for
>>>   mapped_field:mapped_value1
>>> yields results,
>>> however in the result the mapped_value1 does not appear at all,
>>> but instead the orig_value1 appears also in the mapped_field.
>>>
>>> How can I achieve, that the mapped_value appears in the result as well?
>>>
>>>
>>> thank you,
>>>
>>> matej
>>
>>
>

Re: mapping values in fields

Posted by "tech.vronk" <te...@vronk.net>.
the query is:
   mapped_field:mapped_value1

and seems to correctly return the documents.

the mapped_field has attribute stored=true
and also appears in the result (even without requesting it explicitely 
with fl),
just with the orig_value1 instead of mapped_value1

matej

Am 02.10.2012 15:46, schrieb Erick Erickson:
> What's the query you send? I'm guessing a bit here since you
> haven't included it, but try insuring two things:
>
> 1>  your mapped_field is has 'stored="true" '
> 2> you specify (either in your request handler on on the URL) fl=mapped_value
>
> Best
> Erick
>
> On Tue, Oct 2, 2012 at 9:04 AM, tech.vronk <te...@vronk.net> wrote:
>> Hi,
>>
>> I try to map values from one field into other values in another field.
>> For example:
>> original_field: orig_value1
>> mapped_field: mapped_value1
>>
>> with the help of an explicitely defined (N:1) mapping:
>> orig_value1 => mapped_value1
>> orig_value2 => mapped_value1
>> orig_value3 => mapped_value2
>>
>> I have tried to use SynonymFilterFactory
>> for the mapped_field:
>>
>> <fieldtype name="mapped_field" class="solr.TextField">
>>        <analyzer type="index">
>>            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>>            <filter class="solr.SynonymFilterFactory"
>> synonyms="region-map.txt" ignoreCase="true" expand="true"/>
>>        </analyzer>
>>
>> combined with:
>> <copyField src="original_field" dest="mapped_field" />
>>
>>
>> Now, a search for
>>   mapped_field:mapped_value1
>> yields results,
>> however in the result the mapped_value1 does not appear at all,
>> but instead the orig_value1 appears also in the mapped_field.
>>
>> How can I achieve, that the mapped_value appears in the result as well?
>>
>>
>> thank you,
>>
>> matej
>


Re: mapping values in fields

Posted by Erick Erickson <er...@gmail.com>.
What's the query you send? I'm guessing a bit here since you
haven't included it, but try insuring two things:

1>  your mapped_field is has 'stored="true" '
2> you specify (either in your request handler on on the URL) fl=mapped_value

Best
Erick

On Tue, Oct 2, 2012 at 9:04 AM, tech.vronk <te...@vronk.net> wrote:
> Hi,
>
> I try to map values from one field into other values in another field.
> For example:
> original_field: orig_value1
> mapped_field: mapped_value1
>
> with the help of an explicitely defined (N:1) mapping:
> orig_value1 => mapped_value1
> orig_value2 => mapped_value1
> orig_value3 => mapped_value2
>
> I have tried to use SynonymFilterFactory
> for the mapped_field:
>
> <fieldtype name="mapped_field" class="solr.TextField">
>       <analyzer type="index">
>           <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>           <filter class="solr.SynonymFilterFactory"
> synonyms="region-map.txt" ignoreCase="true" expand="true"/>
>       </analyzer>
>
> combined with:
> <copyField src="original_field" dest="mapped_field" />
>
>
> Now, a search for
>  mapped_field:mapped_value1
> yields results,
> however in the result the mapped_value1 does not appear at all,
> but instead the orig_value1 appears also in the mapped_field.
>
> How can I achieve, that the mapped_value appears in the result as well?
>
>
> thank you,
>
> matej