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 Doss <it...@gmail.com> on 2018/05/18 14:23:32 UTC

SOLR: Array Key to Value on Result

Hi,

I am looking for a solution. Lets say we have complete City, State, Country
values in an array (with Multi language), based on user selection I will be
storing only the corresponding keys in the index.

If I place the complete  array inside solr conf or inside the data
directory, is there any component  which can map the key and adds the
corresponding value in the result set?

Eg.

Array: {"1":{"EN":"India","TAM":"\u0b87\u0ba8\u0bcd\u0ba4\u0bbf\u0baf\u0bbe"}}

while getting the result if I pass

country key as 1 & language as EN then the result should have the country
value as India.

Please help to crack this.


Thanks,
Doss.

Re: SOLR: Array Key to Value on Result

Posted by Erick Erickson <er...@gmail.com>.
"The Solr Way" (tm) would be to flatten the data and store multiple
records, i.e.
id          key          lang         lang_display
1_EN     1            EN            india
1_TAM   1            TAM         \u0b87\u0ba8\u0bcd\u0ba4\u0bbf\u0baf\u0bbe

where lang was indexed but possibly not stored and lang_dislplay was
stored but possibly not indexed (or docValues or....)

This can bloat the index if carried too far, since the number of
records becomes the cross product of all the different possibilities.
That said, until you get into the multiple 10s of millions it's
usually not a problem.

[subquery] is going to be somewhat expensive. You're right it'll only
execute on the docs returned, so if rows=10 the subqueries will be
performed only for those 10 docs. But that's 10 *
number_of_subquery_fields so could explode a bit.

Note I had to play a bit with the "id" field since it's akin to a
primary key in a database so must be different for each record you
want to have available.

Or, if you wanted to keep the record as your example, you might just
store {"EN":"India","TAM":"\u0b87\u0ba8\u0bcd\u0ba4\u0bbf\u0baf\u0bbe"}
in, say, a "languages" string field and have the front-end pull out
the right part based on the language desired using your favorite JSON
parser or whatever.

Best,
Erick

On Sat, May 19, 2018 at 9:15 AM, Doss <it...@gmail.com> wrote:
> Hi,
>
> I found a work around for our requirement with the help of Transforming
> Result Documents.
>
> https://lucene.apache.org/solr/guide/7_3/transforming-result-documents.html#subquery
>
> I need insights about the performance impact (if any) this is going to
> create. I assume this transformation is happening after the results being
> obtained by the parent query, so there won't be much performance impact it
> will create, but
>
> we are going to use this functionality for a large and busy index, so before
> taking further steps I need expert opinion.
>
> Thanks,
> Doss.
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Re: SOLR: Array Key to Value on Result

Posted by Doss <it...@gmail.com>.
Hi,

I found a work around for our requirement with the help of Transforming
Result Documents.

https://lucene.apache.org/solr/guide/7_3/transforming-result-documents.html#subquery

I need insights about the performance impact (if any) this is going to
create. I assume this transformation is happening after the results being
obtained by the parent query, so there won't be much performance impact it
will create, but 

we are going to use this functionality for a large and busy index, so before
taking further steps I need expert opinion. 

Thanks,
Doss.



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html