How to handle List<CustomObject> in Solr 6.6

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to handle List<CustomObject> in Solr 6.6

waseem-farooqui
I am new with Solr and using Spring-data-solr to store my complete **pdf**
files with its contents now there raise a situation in which I want to store
the file rating, that can be rate by list of users means I would have object
something like this in my **DataModel** `List<FileRating>` in which
`FileRating` would have `user, comments, date, rating` the response json
structure should be like this

    {
          "document": "Fuzzy based semantic search.pdf",
          "md5Hash": "md5",
          "rated": [
            {
              "user": "John",
              "comments": "Not Very useful",
              "rating": 2,
              "date": "20/10/2018"
            },
            {
              "user": "Terrion",
              "comments": "Useful with context to semantic based fuzzy logics.",
              "rating": 6,
              "date": "20/10/2018"
            }
          ]
        }
  and I not getting any idea how is this possible in solr have looked
`multivalued` type but I don't think it would work in my scenario because at
the end of the day I want to search all documents with its rating and could
be file rated by specific users.

`Solr 6.6`



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
Reply | Threaded
Open this post in threaded view
|

Re: How to handle List<CustomObject> in Solr 6.6

Tim Underwood
Hi,

It sounds like you are looking for the "Nested Child Documents"[1] and
"Block Join Query Parsers"[2] features in Solr.  The terminology is weird
(block join, child/of, parent/which) but it should do what you want.

Do take note of the warning in the docs:

One limitation of indexing nested documents is that the whole block of
> parent-children documents must be updated together whenever any changes are
> required. In other words, even if a single child document or the parent
> document is changed, the whole block of parent-child documents must be
> indexed together.


What this note does not include is that if you delete a parent document you
must also explicitly delete the child documents otherwise they end up being
attached to another parent document.  I forget if this applies when you
re-index a document or not but to be safe I always explicitly delete the
parent and child documents.  There are a number of JIRA tickets floating
around relating to cleaning up the user experience for this.

-Tim

[1]
https://lucene.apache.org/solr/guide/6_6/uploading-data-with-index-handlers.html#UploadingDatawithIndexHandlers-NestedChildDocuments
[2]
https://lucene.apache.org/solr/guide/6_6/other-parsers.html#OtherParsers-BlockJoinQueryParsers

On Tue, Nov 6, 2018 at 12:01 AM waseem-farooqui <[hidden email]>
wrote:

> I am new with Solr and using Spring-data-solr to store my complete **pdf**
> files with its contents now there raise a situation in which I want to
> store
> the file rating, that can be rate by list of users means I would have
> object
> something like this in my **DataModel** `List<FileRating>` in which
> `FileRating` would have `user, comments, date, rating` the response json
> structure should be like this
>
>     {
>           "document": "Fuzzy based semantic search.pdf",
>           "md5Hash": "md5",
>           "rated": [
>             {
>               "user": "John",
>               "comments": "Not Very useful",
>               "rating": 2,
>               "date": "20/10/2018"
>             },
>             {
>               "user": "Terrion",
>               "comments": "Useful with context to semantic based fuzzy
> logics.",
>               "rating": 6,
>               "date": "20/10/2018"
>             }
>           ]
>         }
>   and I not getting any idea how is this possible in solr have looked
> `multivalued` type but I don't think it would work in my scenario because
> at
> the end of the day I want to search all documents with its rating and could
> be file rated by specific users.
>
> `Solr 6.6`
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
>
Reply | Threaded
Open this post in threaded view
|

Re: How to handle List<CustomObject> in Solr 6.6

Shawn Heisey-2
In reply to this post by waseem-farooqui
On 11/6/2018 12:52 AM, waseem-farooqui wrote:

>      {
>  "document": "Fuzzy based semantic search.pdf",
>  "md5Hash": "md5",
>  "rated": [
>    {
>      "user": "John",
>      "comments": "Not Very useful",
>      "rating": 2,
>      "date": "20/10/2018"
>    },
>    {
>      "user": "Terrion",
>      "comments": "Useful with context to semantic based fuzzy logics.",
>      "rating": 6,
>      "date": "20/10/2018"
>    }
>  ]
> }

Solr documents have a flat structure.  There is no normalization like
you have with a relational database.  Think of it like a single database
table with many columns, instead of several database tables working
together.  A complex nested structure in a single document is not possible.

Solr has one feature that might be what you need -- parent/child
documents.  In that scenario, your rating structures would be completely
separate documents, indexed together with the parent document.  To query
it and make use of the dependent structure, you would use the blockjoin
query parser.  I have never used this functionality, so this paragraph
is all I know about it and I cannot help any further.

Thanks,
Shawn