How to use SOLR copyField directive

后端 未结 3 1593
暖寄归人
暖寄归人 2020-12-08 10:50

I have a rather simple SOLR structure, that hold three different fields:

id, text and tags

in the schema.xml I set the following



        
相关标签:
3条回答
  • 2020-12-08 11:16

    The copyField is done when a document is indexed, so it is before the index analyzer. It is really like you had put the same input text in two different fields. But after that, it all depends on the analyzers you defined for both fields.

    0 讨论(0)
  • 2020-12-08 11:17

    I haven't tried using the copyField to append additional text to an existing field. I suppose Solr could concatenate it, or add it as a second value.

    But here's a couple ideas to try:

    1. Experiment with a document where the text field is blank, perhaps not even mentioned as a under the structure. Does it seem to make a difference when tags make it into the main text whether text starts out as totally blank or not?

    2. Declare a second field, call it text2. And then ALSO copy tags into text2 via a second copyField directive. This text2 field won't have anything else in it, presumably not even mentioned in your fields, so for sure it should get the content.

    In both cases you'd check results with the schema browser, as before. I'd be very curious to hear how you find out!

    0 讨论(0)
  • 2020-12-08 11:21

    If you search q=tags:xyz then xyz will not be found because you had sent it not be indexed.

    If you do a default search, yes, it should search the copyfield, however, according to the Solr wiki

    Any number of declarations can be included in your schema, to instruct Solr that you want it to duplicate any data it sees in the "source" field of documents that are added to the index

    I think that having not added 'tags' to index would also cause the copyfield of 'tags' to not be indexed.

    0 讨论(0)
提交回复
热议问题