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 Kamal Palei <pa...@gmail.com> on 2013/05/16 14:37:45 UTC

Adding a field in schema , storing it and use it to search

Hi All

Need help in adding a new field and making use of it during search.

As of today I just search some keywords and whatever document (actually
these are resumes of individuals) is retrieved from SOLR search I take
these as input, then search in mysql for experience, salary etc and then
selected resumes I show as search result.

Say, while searching in SOLR, I want to achieve something as below.

1. Search keywords in those users resume whose experience is greater than 5
years.

To achieve My understanding is
1. I need to define a new field in schema
2. During indexing, add this parameter
3. During search, have a condition like experience >= 5 years


When I will be adding a field , should I add as a normal field one as shown
below

*<field name="experience" type="integer" indexed="true" stored="true"/>*

OR as a dynamic field as shown below

*<dynamicField name="exp_*"  type="double"   indexed="true"  stored="true"
multiValued="false"/>*


And during search, how the condition should look like.

Best regards
Kamal

Re: Adding a field in schema , storing it and use it to search

Posted by Erick Erickson <er...@gmail.com>.
Whether you add it as a dynamic field or "normal" field really doesn't
matter from a Solr perspective. Dynamic fields are exactly like normal
fields, you just don't have to fully specify the name. That said, I
prefer normal fields to prevent typo's from messing me up. If you had
a dynamic field like you indicate then entered esp_55 rather than
exp_55, you'd have to track down why things were wrong, whereas if you
used a normal field, the doc would fail to index and you'd know early.
"fail early" is good.

To search, something like experience:[5 TO *] would do. Note that
there's both inclusive and exclusive syntax here, distinguished by
curly braces or backets (i.e. {} or []) which may be mixed.

Best
Erick

On Thu, May 16, 2013 at 8:37 AM, Kamal Palei <pa...@gmail.com> wrote:
> Hi All
>
> Need help in adding a new field and making use of it during search.
>
> As of today I just search some keywords and whatever document (actually
> these are resumes of individuals) is retrieved from SOLR search I take
> these as input, then search in mysql for experience, salary etc and then
> selected resumes I show as search result.
>
> Say, while searching in SOLR, I want to achieve something as below.
>
> 1. Search keywords in those users resume whose experience is greater than 5
> years.
>
> To achieve My understanding is
> 1. I need to define a new field in schema
> 2. During indexing, add this parameter
> 3. During search, have a condition like experience >= 5 years
>
>
> When I will be adding a field , should I add as a normal field one as shown
> below
>
> *<field name="experience" type="integer" indexed="true" stored="true"/>*
>
> OR as a dynamic field as shown below
>
> *<dynamicField name="exp_*"  type="double"   indexed="true"  stored="true"
> multiValued="false"/>*
>
>
> And during search, how the condition should look like.
>
> Best regards
> Kamal