Filter new - Axiom

Filter Objects are used to filter the results of a given search. They can be passed into the following methods: app.getFields(), app.getHits(), app.getHitCount(), app.getObjects(), AxiomObject.getChildren(), AxiomObject.getChildCount(). Below are the constructors for each of the different types of filters.

Contents

AndFilter()

Description

AndFilter(filters)

Constructor for an And Filter. Returns a filter with an And operation performed on the specified filters.

Parameters

  • filters (Array) - An Array of the Filter/NativeFilter Objects that are to be combined by an And operation. Optionally, any number of individual Filter/NativeFilters can be passed into the constructor as well.

Returns

(Filter) - The resulting Filter Object.

Examples

var filters = [];
filters.push(new Filter({id: "company-picnic"}));
filters.push(new NativeFilter("title: Company*"));
app.getObjects("Post", new AndFilter(filters));

This will return all Axiom Objects of the Post prototype, with an id exactly matching "company-picnic", and a title that starts with "Company". In this case, the id property's index needs to be specified as UNTOKENIZED.


NotFilter()

Description

NotFilter(filter)

Constructor for a Not Filter. Returns a filter with a Not operation performed on the specified filter.

Parameters

  • filter (Filter or NativeFilter) - The filter to perform a Not operation on.

Returns

(Filter) - The resulting Filter Object.

Examples

var filter = new Filter({id: "company-picnic"});
app.getObjects("Post", new NotFilter(filter));

This will return all Axiom Objects of the Post prototype, with an id that is not "company-picnic". In this case, the id property's index needs to be specified as UNTOKENIZED.


Filter()

Description

Filter(filter)

Constructor for the basic filter. This is the filter that should be used when searching for exact matches on untokenized properties.

Parameters

  • filter (Object) - An Object whose property/value pairs the ones to match exactly.

Examples

app.getObjects("Post", new Filter({id: "company-picnic"}));

This will return all Axiom Objects of the Post prototype, with an id exactly matching "company-picnic". In this case, the id property's index needs to be specified as UNTOKENIZED.

Notes

Properties are tokenized by default, so if you want to have a property on your Prototype that can be matched exactly, their index must be specified as untokenized in the prototype.properties file:

id
id.type = String
id.index = UNTOKENIZED


NativeFilter()

Description

NativeFilter(query, option)

Constructor for a Lucene Native Filter. This is the filter that should be used when searching over tokenized properties. All properties are tokenized by default.

Parameters

  • query (String) - A string that utilizes the Lucene Query Syntax.
  • option (String, Optional) - The Analyzer to use, or name the Search Profile. Search profiles can be set up in search.properties.

Examples

app.getObjects("Post", new NativeFilter("title: Company*"));

This will return all Axiom Objects of the Post prototype, with a title that starts with "Company".


OrFilter()

Description

OrFilter(filters)

Constructor for an Or Filter. Returns a filter with an Or operation performed on the specified filters.

Parameters

  • filters (Array) - An Array of the Filter/NativeFilter Objects that are to be combined by an Or operation. Optionally, any number of individual Filter/NativeFilters can be passed into the constructor as well.

Returns

(Filter) - The resulting Filter Object.

Examples

var filters = [];
filters.push(new Filter({id: "company-picnic"}));
filters.push(new NativeFilter("title: Company*"));
app.getObjects("Post", new OrFilter(filters));

This will return all Axiom Objects of the Post prototype, with an id exactly matching "company-picnic", or a title that starts with "Company". In this case, the id property's index needs to be specified as UNTOKENIZED.