Below is my 2 entity class
First Entity
<code>@Entity
@Indexed
public class Course{
@KeywordField
@Column(unique = true)
public String id;
@GenericField
public boolean isActive;
@OneToMany(cascade = CascadeType.ALL)
@IndexedEmbedded
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
public Set<Localization> localizations = new HashSet<>();
}
</code>
<code>@Entity
@Indexed
public class Course{
@KeywordField
@Column(unique = true)
public String id;
@GenericField
public boolean isActive;
@OneToMany(cascade = CascadeType.ALL)
@IndexedEmbedded
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
public Set<Localization> localizations = new HashSet<>();
}
</code>
@Entity
@Indexed
public class Course{
@KeywordField
@Column(unique = true)
public String id;
@GenericField
public boolean isActive;
@OneToMany(cascade = CascadeType.ALL)
@IndexedEmbedded
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
public Set<Localization> localizations = new HashSet<>();
}
Second Entity
<code>@Entity
@Indexed
public class Localization{
@KeywordField
public String languageStr;
@KeywordField(aggregable = Aggregable.YES)
public String localizationType="";
}
</code>
<code>@Entity
@Indexed
public class Localization{
@KeywordField
public String languageStr;
@KeywordField(aggregable = Aggregable.YES)
public String localizationType="";
}
</code>
@Entity
@Indexed
public class Localization{
@KeywordField
public String languageStr;
@KeywordField(aggregable = Aggregable.YES)
public String localizationType="";
}
Sample Localization data:
<code>"localizations": [
{
"languageStr": "zh",
"localizationType": "Orginal"
},
{
"languageStr": "es",
"localizationType": "Subtitled"
},
{
"languageStr": "de",
"localizationType": "Subtitled"
},
{
"languageStr": "en",
"localizationType": "Original"
},
{
"languageStr": "fr",
"localizationType": "Subtitled"
},
{
"languageStr": "ar",
"localizationType": "Subtitled"
},
{
"languageStr": "pt",
"localizationType": "Subtitled"
},
{
"languageStr": "ja",
"localizationType": "Subtitled"
}
]
</code>
<code>"localizations": [
{
"languageStr": "zh",
"localizationType": "Orginal"
},
{
"languageStr": "es",
"localizationType": "Subtitled"
},
{
"languageStr": "de",
"localizationType": "Subtitled"
},
{
"languageStr": "en",
"localizationType": "Original"
},
{
"languageStr": "fr",
"localizationType": "Subtitled"
},
{
"languageStr": "ar",
"localizationType": "Subtitled"
},
{
"languageStr": "pt",
"localizationType": "Subtitled"
},
{
"languageStr": "ja",
"localizationType": "Subtitled"
}
]
</code>
"localizations": [
{
"languageStr": "zh",
"localizationType": "Orginal"
},
{
"languageStr": "es",
"localizationType": "Subtitled"
},
{
"languageStr": "de",
"localizationType": "Subtitled"
},
{
"languageStr": "en",
"localizationType": "Original"
},
{
"languageStr": "fr",
"localizationType": "Subtitled"
},
{
"languageStr": "ar",
"localizationType": "Subtitled"
},
{
"languageStr": "pt",
"localizationType": "Subtitled"
},
{
"languageStr": "ja",
"localizationType": "Subtitled"
}
]
Given the above entity, need to fetch the course where it should match for given languageStr and localizationType inside localizations using hibernate search. For example I want to filter the courses where “languageStr” = “zh” and “localizationType” =”Orginal”, currently it is working as `OR” condition, i am looking for “AND” condition. Any help would be appreciated.