You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by donjose <do...@socgen.com> on 2017/04/17 14:12:23 UTC

Solr Child="true" flag in version 6.4

Hello,

I am facing an issue when i am trying to use child="true" in entity.
For example i am having some relational data in my DB. Please find the
sample JSOn format below
{
Category : "Shirt",
CategoryId : 1
Categoryvalues : [
{
    id : 1,
    size : XL,
   color : red
},
{
    id : 2,
    size : XL,
   color : blue
}

]
}

When i am trying to apply child="true", i am getting flat structure. Not the
same way i defined above. Could you please tell me options to create the
JSON in above mentioned format



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Child-true-flag-in-version-6-4-tp4330312.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Child="true" flag in version 6.4

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
I am not sure I can explain it better than the link I gave. Basically
you select parent records and then use fl=*,[child....] to add
children records into that.

I mostly wanted to make sure you knew about the flatten-by-default search.

Another way is to look for common _root_ field value. It will be same
for all records in the same block (parent, children, grandchildren,
etc). Of course, _root_ field is usually not stored, so it is a bit
hard to get to it. But you can look at all the indexed values that
field has in Admin UI's schema screen and then search by that value to
see how many records show up.

Regards,
   Alex.
----
http://www.solr-start.com/ - Resources for Solr users, new and experienced


On 18 April 2017 at 12:36, donjose <do...@socgen.com> wrote:
> Hello Alex,
>
> Thanks for your reply. This is the first time i am doing with nested
> entities.
> Yes you are right am getting flat list combining parent & child.
> Could you please explain bit more detail, how to apply child transformer for
> the below mentioned response.
>
>
> Response
> ==============
> {
>   "responseHeader":{
>     "status":0,
>     "QTime":0,
>     "params":{
>       "q":"*:*",
>       "indent":"on",
>       "wt":"json",
>       "_":"1492506329597"}},
>   "response":{"numFound":3,"start":0,"docs":[
>       {
>         "color":"Red",
>         "id":"1"},
>       {
>         "color":"Blue",
>         "id":"2"},
>       {
>         "category":["Shirt"],
>         "id":"1",
>         "_version_":1565006509454131200}]
>   }}
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-Child-true-flag-in-version-6-4-tp4330312p4330459.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Child="true" flag in version 6.4

Posted by donjose <do...@socgen.com>.
Hello Alex,

Thanks for your reply. This is the first time i am doing with nested
entities.
Yes you are right am getting flat list combining parent & child.
Could you please explain bit more detail, how to apply child transformer for
the below mentioned response.


Response
==============
{
  "responseHeader":{
    "status":0,
    "QTime":0,
    "params":{
      "q":"*:*",
      "indent":"on",
      "wt":"json",
      "_":"1492506329597"}},
  "response":{"numFound":3,"start":0,"docs":[
      {
        "color":"Red",
        "id":"1"},
      {
        "color":"Blue",
        "id":"2"},
      {
        "category":["Shirt"],
        "id":"1",
        "_version_":1565006509454131200}]
  }}



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Child-true-flag-in-version-6-4-tp4330312p4330459.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Child="true" flag in version 6.4

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
You say you are trying to use child=true, but the definition you gave
does not actually have one. Is it possible you tested with it once,
but then did not keep it for later tests accidentally?

Also, if that`s your first time working with nested entities, the
query returns parents and children all together, so it looks like a
flat list even when it is indexed correctly as nested. It may help to
have child document transformer at least during the initial debug:
https://cwiki.apache.org/confluence/display/solr/Transforming+Result+Documents#TransformingResultDocuments-[child]-ChildDocTransformerFactory

Regards,
   Alex.
----
http://www.solr-start.com/ - Resources for Solr users, new and experienced


On 18 April 2017 at 12:09, donjose <do...@socgen.com> wrote:
> Verbose debug output
> {
>   "responseHeader": {
>     "status": 0,
>     "QTime": 109
>   },
>   "initArgs": [
>     "defaults",
>     [
>       "config",
>       "data-config.xml"
>     ]
>   ],
>   "command": "full-import",
>   "mode": "debug",
>   "documents": [
>     {
>       "category": [
>         "Shirt"
>       ],
>       "id": [
>         "1"
>       ],
>       "_version_": [
>         1565006509454131200
>       ],
>       "_root_": [
>         "1"
>       ]
>     }
>   ],
>   "verbose-output": [
>     "entity:ASSETCATEGORY",
>     [
>       "document#1",
>       [
>         "query",
>         "SELECT id, category from category",
>         "time-taken",
>         "0:0:0.34",
>         null,
>         "----------- row #1-------------",
>         "CATEGORY",
>         "Shirt",
>         "ID",
>         "1",
>         null,
>         "---------------------------------------------",
>         "entity:Values",
>         [
>           "query",
>           "SELECT id,catsize,color from categoryvalues where categoryid =
> 1",
>           "time-taken",
>           "0:0:0.22",
>           null,
>           "----------- row #1-------------",
>           "CATSIZE",
>           "XL",
>           "COLOR",
>           "Red",
>           "ID",
>           "1",
>           null,
>           "---------------------------------------------",
>           null,
>           "----------- row #2-------------",
>           "CATSIZE",
>           "XL",
>           "COLOR",
>           "Blue",
>           "ID",
>           "2",
>           null,
>           "---------------------------------------------"
>         ]
>       ],
>       "document#2",
>       []
>     ]
>   ],
>   "status": "idle",
>   "importResponse": "",
>   "statusMessages": {
>     "Total Requests made to DataSource": "2",
>     "Total Rows Fetched": "3",
>     "Total Documents Processed": "1",
>     "Total Documents Skipped": "0",
>     "Full Dump Started": "2017-04-18 09:08:33",
>     "": "Indexing completed. Added/Updated: 1 documents. Deleted 0
> documents.",
>     "Committed": "2017-04-18 09:08:33",
>     "Time taken": "0:0:0.94"
>   }
> }
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-Child-true-flag-in-version-6-4-tp4330312p4330451.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Child="true" flag in version 6.4

Posted by donjose <do...@socgen.com>.
Verbose debug output
{
  "responseHeader": {
    "status": 0,
    "QTime": 109
  },
  "initArgs": [
    "defaults",
    [
      "config",
      "data-config.xml"
    ]
  ],
  "command": "full-import",
  "mode": "debug",
  "documents": [
    {
      "category": [
        "Shirt"
      ],
      "id": [
        "1"
      ],
      "_version_": [
        1565006509454131200
      ],
      "_root_": [
        "1"
      ]
    }
  ],
  "verbose-output": [
    "entity:ASSETCATEGORY",
    [
      "document#1",
      [
        "query",
        "SELECT id, category from category",
        "time-taken",
        "0:0:0.34",
        null,
        "----------- row #1-------------",
        "CATEGORY",
        "Shirt",
        "ID",
        "1",
        null,
        "---------------------------------------------",
        "entity:Values",
        [
          "query",
          "SELECT id,catsize,color from categoryvalues where categoryid =
1",
          "time-taken",
          "0:0:0.22",
          null,
          "----------- row #1-------------",
          "CATSIZE",
          "XL",
          "COLOR",
          "Red",
          "ID",
          "1",
          null,
          "---------------------------------------------",
          null,
          "----------- row #2-------------",
          "CATSIZE",
          "XL",
          "COLOR",
          "Blue",
          "ID",
          "2",
          null,
          "---------------------------------------------"
        ]
      ],
      "document#2",
      []
    ]
  ],
  "status": "idle",
  "importResponse": "",
  "statusMessages": {
    "Total Requests made to DataSource": "2",
    "Total Rows Fetched": "3",
    "Total Documents Processed": "1",
    "Total Documents Skipped": "0",
    "Full Dump Started": "2017-04-18 09:08:33",
    "": "Indexing completed. Added/Updated: 1 documents. Deleted 0
documents.",
    "Committed": "2017-04-18 09:08:33",
    "Time taken": "0:0:0.94"
  }
}



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Child-true-flag-in-version-6-4-tp4330312p4330451.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Child="true" flag in version 6.4

Posted by Mikhail Khludnev <gg...@gmail.com>.
Hello,

This is puzzling. Are you sure you have recent DIH jar at that core?
Sometimes the old one can remain at lib directory.
One odd thing in the config is that category values are not limited with
something like WHERE categoryvalues.categoryid=${category.id}
Can you share verbose debug output?


18 апр. 2017 г. 8:48 пользователь "donjose" <do...@socgen.com>
написал:

> I am getting flat structure.
> Expected Result :
> {
>  Category : "Shirt",
>  CategoryId : 1
>  Categoryvalues : [
>  {
>      id : 1,
>      size : XL,
>     color : red
>  },
>  {
>      id : 2,
>      size : XL,
>     color : blue
>  }
>
>  ]
> }
>
> Result i am getting:
>  Categoryvalues :
>  {
>      id : 1,
>      Category : "Shirt",
>      CategoryId : 1,
>      size : XL,
>      color : red
>  }
> ,
>  {
>      id : 2,
>      Category : "Shirt",
>      CategoryId : 1,
>      size : XL,
>     color : blue
>  }
>
>
>
> Data-config.xml
> ===================
> <dataConfig>
>     <dataSource driver="oracle.jdbc.OracleDriver" url="jdbcurl"
> user="username" password="password" />
>     <document name="Categories">
>         <entity name="ASSETCATEGORY" query="SELECT id, categoryid, category
> from category">
>             <field column="id" name="id" />
>             <field column="categoryid" name="categoryid" />
>             <field column="category" name="category" />
>             <entity name="Values" query="SELECT id,size,color from
> categoryvalues">
>                     <field column="id" name="id" />
>                     <field column="size" name="size" />
>                     <field column="color" name="color" />
>             </entity>
>         </entity>
>      </document
> </dataconfig>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble
> .com/Solr-Child-true-flag-in-version-6-4-tp4330312p4330437.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Solr Child="true" flag in version 6.4

Posted by donjose <do...@socgen.com>.
I am getting flat structure.
Expected Result : 
{ 
 Category : "Shirt", 
 CategoryId : 1 
 Categoryvalues : [ 
 { 
     id : 1, 
     size : XL, 
    color : red 
 }, 
 { 
     id : 2, 
     size : XL, 
    color : blue 
 } 
 
 ] 
}

Result i am getting: 
 Categoryvalues :  
 { 
     id : 1, 
     Category : "Shirt", 
     CategoryId : 1,
     size : XL, 
     color : red 
 }
, 
 {
     id : 2, 
     Category : "Shirt", 
     CategoryId : 1,
     size : XL, 
    color : blue 
 }



Data-config.xml
===================
<dataConfig>
    <dataSource driver="oracle.jdbc.OracleDriver" url="jdbcurl"
user="username" password="password" />
    <document name="Categories">
        <entity name="ASSETCATEGORY" query="SELECT id, categoryid, category
from category">
	    <field column="id" name="id" />
	    <field column="categoryid" name="categoryid" />
            <field column="category" name="category" />
	    <entity name="Values" query="SELECT id,size,color from categoryvalues">
		    <field column="id" name="id" />
        	    <field column="size" name="size" />
	            <field column="color" name="color" />
	    </entity>
	</entity>
     </document
</dataconfig>



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Child-true-flag-in-version-6-4-tp4330312p4330437.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Child="true" flag in version 6.4

Posted by Mikhail Khludnev <mk...@apache.org>.
Hello,
How do you index exactly?
How do you query exactly?
What do you get and how it differs from your expectation?

On Mon, Apr 17, 2017 at 5:12 PM, donjose <do...@socgen.com>
wrote:

> Hello,
>
> I am facing an issue when i am trying to use child="true" in entity.
> For example i am having some relational data in my DB. Please find the
> sample JSOn format below
> {
> Category : "Shirt",
> CategoryId : 1
> Categoryvalues : [
> {
>     id : 1,
>     size : XL,
>    color : red
> },
> {
>     id : 2,
>     size : XL,
>    color : blue
> }
>
> ]
> }
>
> When i am trying to apply child="true", i am getting flat structure. Not
> the
> same way i defined above. Could you please tell me options to create the
> JSON in above mentioned format
>
>
>
> --
> View this message in context: http://lucene.472066.n3.
> nabble.com/Solr-Child-true-flag-in-version-6-4-tp4330312.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Sincerely yours
Mikhail Khludnev