Model.search()
experimental
WARNING
Currently, the full-text search feature is EXPERIMENTAL.
Still, we strongly suggest to use it in some little parts of your application.
You can decide which fields should be indexed on Elasticsearch.
TIP
You can find more information in Full-text search section.
TIP
You should review the Elasticsearch Configs and the Search Configs
For example, in the following example, only the name
and surname
fields will be indexed on the Elasticsearch.
ts
import { Model } from "axe-api";
class User extends Model {
get fillable() {
return ["name", "surname", "email"];
}
get search() {
return ["name", "surname"];
}
}
export default User;
After that definition:
- Axe API creates the indexes automatically in the initialization process.
- Axe API saves, updates, and deletes the data on the index by using the primary key.
WARNING
You MUST activate the SEARCH handler to allow HTTP clients are able to use the full-text search feature.
TIP
You can manipulate the search query by overriding the getSearchQuery() function.