Hi Erik,
first of all, thanks for your reply.

The "source" of my problems is the fact that I do not know in advance the
field names. Users are allowed to decide they own field names, they can,
at runtime, add new fields and different Lucene documents might have
different field names.

So, in addition to some custom and known field names, I have in my
schema.xml file a dynamicField:

  <dynamicField name="*" type="text" indexed="true" stored="true"
multiValued="true" />

The corresponding fieldType is:

    <fieldType name="text" class="solr.TextField">
      <analyzer type="index">
        ...
      </analyzer>
      <analyzer type="query">
        ...
      </analyzer>
    </fieldType>

This allows me to specify a fixed (i.e. it cannot change at runtime) and
"common" (i.e. it's the same for all dynamicField with name="*") set of
analyzers.

At the same time, in my Lucene application, users are allowed to configure
at runtime different analyzers per field. With Lucene I achieve this
using a PerFieldAnalyzerWrapper at indexing (i.e. IndexWriter and
IndexModifier
allow me to specify an Analyzer in their constructors) and query time
(i.e. QueryParser allows me to specify an Analyzer in its constructor).

Dynamic field patterns allows me to create "groups" of different types of
fields, but they will expose the users to the field patterns itself and remove
their freedom to chose field names as they want.

Perhaps, another way to express my problem is: could I use a
PerFieldAnalyzerWrapper in the above <fieldType> section?
If I do that, how can I configure it at runtime?

Thanks again,
Paolo

On 5 May 2010 14:19, Erik Hatcher <erik.hatc...@gmail.com> wrote:
> Paolo,
>
> Solr takes care of associating fields with the proper analysis defined in
> schema.xml already.  This, of course, depends on which query parser you're
> using, but both the standard Solr query parser and dismax do the right thing
> analysis-wise automatically.
>
> But, I think you need to elaborate on what you're doing in your Lucene
> application to know more specifically.  A dynamic field specification in
> Solr is associated with only a single field type, so you'll want to use
> different dynamic field patterns for different types of fields.
>
>        Erik
>
> On May 5, 2010, at 9:14 AM, Paolo Castagna wrote:
>
>> Hi,
>> I have an existing Lucene application which I want to port to Solr.
>>
>> A scenario I need to support requires me to use dynamic fields
>> with Solr, since users can add new fields at runtime.
>>
>> At the same time, the existing Lucene application is using a
>> PerFieldAnalyzerWrapper in order to use different analyzers
>> for different fields.
>>
>> One possible solution (server side) requires a custom QParser
>> which would use a PerFieldAnalyzerWrapper, but perhaps
>> there is a better (client side only) way to do that.
>>
>> Do you have any suggestion on how I could use per field
>> analyzers with dynamic fields?
>>
>> Regards,
>> Paolo
>
>

Reply via email to