Question

I need help indexing this data in solr.

Assume that i have this kind of a students database. I want to index this data in solr and want to be able to search by tested subjects and their percentile. The subjects that the student has taken might differ among students and its not a fixed schema. So, i cant have the subject name as a field name.

I tried exploring dynamic fields but cant seem to be figure out how will i query by the percentile scored.

E.g. i want to filter by all students who have been tested for Math, but only have fared 90 percentil or higher. I also independently want to search by City, name or a combined query between name, address and the tested subjects and their percentil.

{
Name: Max Junior,
Address: Twin peaks
City : ,San francisco,
Grade: 1, 
Subjects: ["Math", "Science", "English"]
Tested Subjects: 
[
{name: Math, percentile: 95},
{name: Science, percentile: 85} 
]
},
{
Name: Alicia Alex,
Address: Nob Hill,
City: San Mateo,
Grade: 1, 
Subjects: ["Math", "English", "Craft"]
Tested Subjects: 
[
{name: Math, percentile: 65},
{name: Science, percentile: 78} 
]
}

Any help is greatly appreciated.

Thanks a lot

Was it helpful?

Solution

I assume you have some unique ID to identify different subjects. For instance Maths subject as 1234, science as 2345. In that case you can index the Math percentile against subject1234_i (assuming percentile in integer value). You can then query for this field as

subject1234_i:[90 TO *]

Refer to Solr query syntax

Other fields like Name, City can be defined as static as those seems common for each student.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top