Get Paramter Names

Hi,

Is it possible to confirm if an index has as specific parameter using the API?

i.e. IF index_a HAS parameter “description” RETURN true/false

Hi @rachid.otsmane,

While there is no existing API method that will answer something like hasParameter RETURN true/false, you could check using attributesToRetrieve.

You could send a query, limit attributesToRetrieve to the attribute you are checking, and then see if it exists in the hit, like below:

index.search(
  {
    query: '',
    attributesToRetrieve: ['someAttribute'],
    hitsPerPage: 1,
  },
  function searchDone(err, content) {
    if (err) throw err;
    if (!content.hits[0].someAttribute) {
      return console.log('Attribute does not exist');
    }
    /// handle if exists
  }
);

Hope that helps!

Hi @ajay.david, thanks for the reply. Yes that is useful. We eventually added a new parameter to describe the type of index and use that to send it down the appropriate path.

1 Like