Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-2483

DIH - an uppercase problem in query parameters

    XMLWordPrintableJSON

Details

    Description

      I have two tables called "PROBLEM" and "KOMENTAR"(means 'comment' in English) in DB. One problem can have more comments. I want to index them all.
      schema.xml looks as follows
      ... some fields ...
      <field name="problem_id" type="string" stored="true" required="true"/>
      ... some fields...

      data-config.xml:
      <document name="problemy">
      <entity name="problem" query="select to_char(id) as problem_id, nazov as problem_nazov, cislo as problem_cislo, popis as problem_popis from problem" pk="problem_id">
      <entity name="komentar" query="select id as komentar_id, nazov as komentar_nazov, text as komentar_text from komentar where to_char(fk_problem)='${problem.PROBLEM_ID}'"/>
      </entity>
      </document>

      If you write '${problem.PROBLEM_ID}' in lower case, i.e. '${problem.problem_id}' SOLR will not import the inner entity. Seems strange to me and it took me some time to figure this out.

      Note that primary key in "PROBLEM" is called "ID". I defined the alias "problem_id" (yes,lower case) in SQL. In schema, there is this field defined as "problem_id" again in lower case. But, when I run
      http://localhost:8983/solr/dataimport?command=full-import&debug=true&verbose=on
      so I can see some debug information there is this part
      ...
      <lst name="verbose-output">

      <lst name="entity:problem">

      <lst name="document#1">

      <str name="query">
      select to_char(id) as problem_id, nazov as problem_nazov, cislo as problem_cislo, popis as problem_popis from problem
      </str>
      <str name="time-taken">0:0:0.465</str>
      <str>----------- row #1-------------</str>
      <str name="PROBLEM_NAZOV">test zodpovedneho</str>
      <str name="PROBLEM_ID">2533274790395945</str>
      <str name="PROBLEM_CISLO">2010093000004</str>
      <str name="PROBLEM_POPIS">csfdewafedewfw</str>
      <str>---------------------------------------------</str>

      <lst name="entity:komentar">

      <str name="query">
      select id as komentar_id, nazov as komentar_nazov, text as komentar_text from komentar where to_char(fk_problem)='2533274790395945'
      </str>
      ...

      where you can see that, internally, the fields of "PROBLEM" are represented in uppercase despite the user (me) had not defined them this way. The result is I guess that parameter referring to the parent entity ${entity.field} should always be in uppercase, i.e. ${entity.FIELD}.

      Here is an example of the indexed entity as written after full-import command with debug and verbose on:
      <arr name="documents">

      <lst>

      <arr name="problem_nazov">
      <str>test zodpovedneho</str>
      </arr>

      <arr name="problem_id">
      <str>2533274790395945</str>
      </arr>

      <arr name="problem_cislo">
      <str>2010093000004</str>
      </arr>

      <arr name="problem_popis">
      <str>csfdewafedewfw</str>
      </arr>

      <arr name="komentar_id">
      <str>java.math.BigDecimal:5066549580791985</str>
      </arr>

      <arr name="komentar_text">
      <str>a.TXT</str>
      </arr>
      </lst>

      here are the field names in lower case. I consider this as a bug. Maybe I am wrong and its a feature. I work with SOLR only for few days.

      Attachments

        Issue Links

          Activity

            People

              arafalov Alexandre Rafalovitch
              lubot Lubo Torok
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: