1

That is probably a bad title...

But let's say I have a bunch of strings in a multivalue field

<field name="stringweights" type="text_nostem" indexed="true" stored="true" multiValued="true"/>

Sample data might be:

history:10
geography:33
math:29

Now I want to write a fq where I select all records in solr where:

  1. stringweights starts with "geography:"
  2. and where the integer value after "geography:" is >= 10.

Is it possible to write a solr query like that?

(It's not possible to create an integer field in the solr schema named "geography", another called "math" etc because these string portions of the field are unknown at design time and can be many hundreds / thousands of different values.)

user85116
  • 4,422
  • 7
  • 35
  • 33

1 Answers1

1

You may want to look into dynamic fields. Declare a dynamic field in your schema like:

<dynamicField name="stringweight_*" type="integer" indexed="true" stored="true"/>

Then you can have your docs like:

stringweight_history: 10
stringweight_geography: 33
stringweight_math: 29

Your filter query is then simply:

fq=stringweight_geography:[10 TO *]

You may need to build a custom indexer for doing this. Or use a script transformer with data import handler as mentioned here: Dynamic column names using DIH (DataImportHandler).

Community
  • 1
  • 1
arun
  • 10,685
  • 6
  • 59
  • 81