Thanks Shawn.

It looks to me that SolrInputDocument.addField() is either missnamed or
isn't well implemented.

When it is called on a field that doesn't exist in the schema, it will
create that field and give it a type based on the data.  Not only that, it
will set default values.  For example, this call

    SolrInputDocument doc = new SolrInputDocument();
    doc.addField("Company", "ACM company");

Will create the following:

    <field name="Company" type="text_general"/>
    <copyField source="Company" dest="Company_str" maxChars="256"/>

Since this is happening without the caller knowing it (this is not
documented) it leads to search issues (the intended analyzer will not be
used to name one).

It looks to me that the only way I can fix this is to first create the
field type first and then call addField() passing it the field I
just created.  To that end, I cannot find a SolrJ API to create a field
type.  Is that the case?

Steven.


On Sun, Feb 14, 2021 at 7:17 PM Shawn Heisey <apa...@elyograg.org> wrote:

> On 2/14/2021 9:00 AM, Steven White wrote:
> > It looks like I'm misusing SolrJ API  SolrInputDocument.addField() thus I
> > need clarification.
> >
> > Here is an example of what I have in my code:
> >
> >      SolrInputDocument doc = new SolrInputDocument();
> >      doc.addField("MyFieldOne", "some data");
> >      doc.addField("MyFieldTwo", 100);
> >
> > The above code is creating 2 fields for me (if they don't exist already)
> > and then indexing the data to those fields.  The data is "some data" and
> > the number 100  However, when the field is created, it is not using the
> > field type that I custom created in my schema.  My question is, how do I
> > tell addField() to use my custom field type?
>
> There is no way in SolrJ code to control which fieldType is used.  That
> is controlled solely by the server-side schema definition.
>
> How do you know that Solr is not using the correct fieldType?  If you
> are looking at the documents returned by a search and aren't seeing the
> transformations described in the schema, you're looking in the wrong place.
>
> Solr search results always returns what was originally sent in for
> indexing.  Only Update Processors (defined in solrconfig.xml, not the
> schema) can affect what gets returned in results, fieldType definitions
> NEVER affect data returned in search results.
>
> Thanks,
> Shawn
>

Reply via email to