Use a field type that is tokenized based on ,
(i.e. each entry in your list results in a separate token). You can do this by using a SimplifiedRegularExpressionPatternTokenizer:
<fieldType name="text" class="solr.TextField">
<analyzer>
<tokenizer class="solr.SimplePatternTokenizerFactory" pattern="[^,]+"/>
</analyzer>
</fieldType>
Query the index by asking for documents having both tokens present fq=field:(JSON AND AngularJS)
.
(After update of question)
First - your field seems to be a string field, and not a TextField.
To add a field through the API with the correct definition:
curl -X POST -H 'Content-type:application/json' --data-binary '{
"add-field-type" : {
"name":"comma-separated-list",
"class":"solr.TextField",
"positionIncrementGap":"100",
"analyzer" : {
"tokenizer":{
"class":"solr.SimplePatternTokenizerFactory", "pattern": "[^,]+" },
}
}
}
}' http://localhost:8983/solr/collectionname/schema
After adding a set of example documents:
[
{
"langs":"JSON,AngularJS,Microsoft Visual Basic",
"id":"foo",
"address":"None",
"_version_":1606953238273196032},
{
"langs":"JSON,AngularJS",
"id":"foo2",
"address":"None",
"_version_":1606953238277390336},
{
"langs":"JSON,Microsoft Visual Basic",
"id":"foo3",
"address":"None",
"_version_":1606953238278438912},
{
"langs":"AngularJS,JSON",
"id":"foo4",
"address":"None",
"_version_":1606953238278438913}]
And then querying using fq=langs:(JSON AND AngularJS)&q=*:*)
:
{
"langs":"JSON,AngularJS,Microsoft Visual Basic",
"id":"foo",
"address":"None",
"_version_":1606953238273196032},
{
"langs":"JSON,AngularJS",
"id":"foo2",
"address":"None",
"_version_":1606953238277390336},
{
"langs":"AngularJS,JSON",
"id":"foo4",
"address":"None",
"_version_":1606953238278438913}]
The document that didn't have AngularJS
defined has been left out.