Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Faceting on array fields #86

Open
Jagdeep1 opened this issue Jun 19, 2012 · 2 comments
Open

Faceting on array fields #86

Jagdeep1 opened this issue Jun 19, 2012 · 2 comments

Comments

@Jagdeep1
Copy link

In the current corona implementation array is not a range supported data type https://github.com/marklogic/Corona/wiki/Supported-Range-Datatypes
I have a JSON document with structure like ... "aothor":"name", "published_date":"20-10-2011", "nouns":["n1","n2"], ....

Here I want to do faceting on "nouns" field which has array data type.

@ryangrimm
Copy link
Contributor

You are correct, at this time there is no support for adding a range index on a JSON array. However, I anticipate that the next major version of MarkLogic server will make supporting this rather trivial. In the meantime there are a couple options:

  1. I could change the datamodel that's backing the JSON documents to support this (pretty painful for me)
  2. You could use the support for XML strings inside JSON documents as a stopgap solution. Here's how I'd do that if I were you:

I'd create another key, "nouns::xml". Inside this key I'ld put a quoted string of XML that contains a element for every item in the array. So it would look something like:

{"author":"name", "published_date":"20-10-2011", "nouns":["n1","n2"], "nouns::xml":{"<nouns><noun>n1</noun><noun>n2</noun></nouns>"}}

You'd then create an XML element range index on "noun" and query using that.

I know this isn't pretty and I'd like to have a better solution in place today but it is what it is.

@Jagdeep1
Copy link
Author

Thanks.. I will try using till you come up with native support for array objects.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants