Home > Back-end >  How to index nullable fields on azure search
How to index nullable fields on azure search

Time:05-24

I'm using nodejs to create the index on azure search,

 {

        "name": "price_positioning",

        "type": "Edm.ComplexType",

        "fields": [

            {

                "name": "id",

                "type": "Edm.Double",

                "filterable": false

            },

            {

                "name": "name",

                "type": "Edm.String",

                "searchable": true,

                "filterable": true,

                "sortable": true,

                "facetable": true

            }

        ]

    },

and the json is :

[{"price_positioning":""},
{
"price_positioning":{"id":1.1,"name":"test"}
 }]

when I try to execute the progam it gives this error : "The request is invalid. Details: parameters : A 'PrimitiveValue' node with non-null value was found when trying to read the value of the property 'price_positioning'; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.\r\n"

do you know please how can we index nullable fields ?

CodePudding user response:

If you don't have a value for price_positioning, you can either leave that attribute out of the request completely or mark it as null.

For example, setting the value to null like this will work:

"price_positioning": null

Or if you preferred, you could still create the price_positioning object and mark each of its attributes as null:

"price_positioning": {
    "id": null,
    "name": null
}
  • Related