Solr
  1. Solr
  2. SOLR-3336

SolrEntityProcessor should substitute params at query time, not startup time

    Details

      Description

      The SolrEntityProcessor performs variable substitution at startup, not at query time. This means that this technique cannot work:

      <entity get a document>
         <field SomeField/>
         <entity SolrEntityProcessor query="${SomeField}"/>
      </entity>
      

      The SEP should substitute the new value of SomeField into each query string.

        Issue Links

          Activity

          Hide
          Martijn van Groningen added a comment -

          If I remember correctly variable substitution can happen at query time for most of the DIH configuration. I think the following configuration would work:

          <entity name="ent1" ...>
             <field SomeField/>
             <entity SolrEntityProcessor query="${ent1.SomeField}"/>
          </entity>
          
          Show
          Martijn van Groningen added a comment - If I remember correctly variable substitution can happen at query time for most of the DIH configuration. I think the following configuration would work: <entity name= "ent1" ...> <field SomeField/> <entity SolrEntityProcessor query= "${ent1.SomeField}" /> </entity>
          Hide
          Michael Kroh added a comment -
          Show
          Michael Kroh added a comment - As this was coming from my entry in mail-list here is the link to my configuration file: http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201204.mbox/%3cOFC36D959B.9529428B-ONC12579D8.0063ACA8-C12579D8.006424F3@basf-c-s.be%3e
          Hide
          Lance Norskog added a comment -

          All variable substitution happens in SolrEntityProcessor.firstInit(), not doQuery(). doQuery() fetches the stored query string and executes it.

          This makes the SEP useful for the outermost entity, but not the inner entities.

          Show
          Lance Norskog added a comment - All variable substitution happens in SolrEntityProcessor.firstInit(), not doQuery(). doQuery() fetches the stored query string and executes it. This makes the SEP useful for the outermost entity, but not the inner entities.
          Hide
          Martijn van Groningen added a comment -

          This makes the SEP useful for the outermost entity, but not the inner entities.

          That makes sense.

          Show
          Martijn van Groningen added a comment - This makes the SEP useful for the outermost entity, but not the inner entities. That makes sense.
          Hide
          Michael Kroh added a comment -

          Hi Martijn,
          as discussed in Boston please find attached my modified Version of SolrEntityProvessor. The version is able to hande the entity on Top Level.
          Best regards
          Michael

          Show
          Michael Kroh added a comment - Hi Martijn, as discussed in Boston please find attached my modified Version of SolrEntityProvessor. The version is able to hande the entity on Top Level. Best regards Michael
          Hide
          Martijn van Groningen added a comment -

          Thanks Micheal! I'll take a look at it.

          Show
          Martijn van Groningen added a comment - Thanks Micheal! I'll take a look at it.
          Hide
          Martijn van Groningen added a comment -

          Looks good. All params but the url and wt parameter are not resolved at query time. I guess that is just fine.

          Show
          Martijn van Groningen added a comment - Looks good. All params but the url and wt parameter are not resolved at query time. I guess that is just fine.
          Hide
          Martijn van Groningen added a comment -

          Committed to trunk and 3.6 branch.

          Show
          Martijn van Groningen added a comment - Committed to trunk and 3.6 branch.
          Hide
          Lance Norskog added a comment -

          Cool! Thanks, everyone.

          Show
          Lance Norskog added a comment - Cool! Thanks, everyone.
          Hide
          Uwe Schindler added a comment -

          Bulk close for 3.6.1

          Show
          Uwe Schindler added a comment - Bulk close for 3.6.1
          Hide
          Shalin Shekhar Mangar added a comment -

          The fix is not complete. Although the variable substitution was moved to the doQuery() method but because of the initDone boolean flag, the doQuery method is actually executed only once. Hence subsequent executions of child SolrEntityProcessor will either return records from the first execution or return no records at all.

          http://www.mail-archive.com/solr-user@lucene.apache.org/msg88002.html
          http://stackoverflow.com/questions/15734308/solrentityprocessor-is-called-only-once-for-sub-entities?lq=1

          Show
          Shalin Shekhar Mangar added a comment - The fix is not complete. Although the variable substitution was moved to the doQuery() method but because of the initDone boolean flag, the doQuery method is actually executed only once. Hence subsequent executions of child SolrEntityProcessor will either return records from the first execution or return no records at all. http://www.mail-archive.com/solr-user@lucene.apache.org/msg88002.html http://stackoverflow.com/questions/15734308/solrentityprocessor-is-called-only-once-for-sub-entities?lq=1
          Hide
          Hoss Man added a comment -

          Shalin: since this issue has already been recorded in the CHANGES for 3.6.1 and 4.0-ALPHA you should not attempt to re-open and re-fix under the label of this issue – open a new bug and link them so once the "new" fix is applied it can be coherently recorded and there won't be any confusion about when the various pieces of the problem were resolved.

          Show
          Hoss Man added a comment - Shalin: since this issue has already been recorded in the CHANGES for 3.6.1 and 4.0-ALPHA you should not attempt to re-open and re-fix under the label of this issue – open a new bug and link them so once the "new" fix is applied it can be coherently recorded and there won't be any confusion about when the various pieces of the problem were resolved.
          Hide
          Shalin Shekhar Mangar added a comment -

          Closing per Hoss's comment.

          Show
          Shalin Shekhar Mangar added a comment - Closing per Hoss's comment.

            People

            • Assignee:
              Unassigned
              Reporter:
              Lance Norskog
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development