I need an advice to increase my search performance. Write now I’m developing a backend service with node.js and couchbase. My index definition is as following:
{"name": "product_search",
"type": "fulltext-index",
"params": {
"doc_config": {
"docid_prefix_delim": "",
"docid_regexp": "",
"mode": "type_field",
"type_field": "_type"
},
"mapping": {
"default_analyzer": "standard",
"default_datetime_parser": "dateTimeOptional",
"default_field": "_all",
"default_mapping": {
"default_analyzer": "",
"dynamic": true,
"enabled": false
},
"default_type": "_default",
"docvalues_dynamic": true,
"index_dynamic": true,
"store_dynamic": false,
"type_field": "_type",
"types": {
"Product": {
"default_analyzer": "",
"dynamic": false,
"enabled": true,
"properties": {
"categories": {
"default_analyzer": "",
"dynamic": true,
"enabled": true,
"properties": {
"\"$ref\"": {
"enabled": true,
"dynamic": false,
"fields": [
{
"analyzer": "keyword",
"index": true,
"name": "\"$ref\"",
"type": "text"
}
]
}
}
},
"description": {
"default_analyzer": "",
"dynamic": false,
"enabled": true,
"properties": {
"long": {
"enabled": true,
"dynamic": false,
"fields": [
{
"include_in_all": true,
"index": true,
"name": "long",
"type": "text"
}
]
},
"short": {
"enabled": true,
"dynamic": false,
"fields": [
{
"include_in_all": true,
"index": true,
"name": "short",
"type": "text"
}
]
}
}
},
"isVisible": {
"enabled": true,
"dynamic": false,
"fields": [
{
"include_term_vectors": true,
"index": true,
"name": "isVisible",
"type": "boolean"
}
]
},
"brandName": {
"enabled": true,
"dynamic": false,
"fields": [
{
"include_in_all": true,
"index": true,
"name": "brandName",
"type": "text"
}
]
},
"fobPriceMax": {
"enabled": true,
"dynamic": false,
"fields": [
{
"name": "fobPriceMax",
"store": true,
"type": "text"
}
]
},
"fobPriceMin": {
"enabled": true,
"dynamic": false,
"fields": [
{
"name": "fobPriceMin",
"store": true,
"type": "text"
}
]
},
"fobUnit": {
"enabled": true,
"dynamic": false,
"fields": [
{
"name": "fobUnit",
"store": true,
"type": "text"
}
]
},
"isActive": {
"enabled": true,
"dynamic": false,
"fields": [
{
"include_term_vectors": true,
"index": true,
"name": "isActive",
"type": "boolean"
}
]
},
"fobCurrency": {
"enabled": true,
"dynamic": false,
"fields": [
{
"name": "fobCurrency",
"store": true,
"type": "text"
}
]
},
"keywords": {
"enabled": true,
"dynamic": false,
"fields": [
{
"analyzer": "keyword",
"include_in_all": true,
"index": true,
"name": "keywords",
"type": "text"
}
]
},
"mainPicture": {
"enabled": true,
"dynamic": false,
"fields": [
{
"name": "mainPicture",
"store": true,
"type": "text"
}
]
},
"minOrderQuan": {
"enabled": true,
"dynamic": false,
"fields": [
{
"name": "minOrderQuan",
"store": true,
"type": "text"
}
]
},
"minOrderUnit": {
"enabled": true,
"dynamic": false,
"fields": [
{
"name": "minOrderUnit",
"store": true,
"type": "text"
}
]
},
"name": {
"enabled": true,
"dynamic": false,
"fields": [
{
"include_in_all": true,
"index": true,
"name": "name",
"store": true,
"type": "text"
}
]
},
"variationSerials": {
"enabled": true,
"dynamic": false,
"fields": [
{
"analyzer": "keyword",
"index": true,
"name": "variationSerials",
"type": "text"
}
]
}
}
}
}
},
"store": {
"indexType": "scorch",
"kvStoreName": "mossStore"
}
},
"sourceType": "couchbase",
"sourceName": "PTTTradeTest",
"sourceUUID": "7028f16e80f993f5d5f60c93e7eb1147",
"sourceParams": {},
"planParams": {
"maxPartitionsPerPIndex": 171,
"numReplicas": 0
},
"uuid": "7e334514e30a900d"}
And my search code:
Product.searchAsync = function (term, categoryId, variations, limit, skip, sort) {
return new Promise(function (resolve, reject) {
var SearchQuery = Couchbase.SearchQuery;
var SearchFacet = Couchbase.SearchFacet;
var tqs = []
if (term) {
tqs.push(SearchQuery.match(term)); // It search in default field, here it's _all
}
if (categoryId) {
tqs.push(SearchQuery.term(categoryId).field("categories.$ref"));
}
if (variations) {
variations.map(v => tqs.push(SearchQuery.match(v).field("variationSerials")));
}
tqs.push(SearchQuery.booleanField(true).field("isActive"));
tqs.push(SearchQuery.booleanField(true).field("isVisible"));
var conjunction = SearchQuery.conjuncts(tqs);
var query = SearchQuery.new("product_search", conjunction);
query.addFacet("variations", SearchFacet.term("variationSerials", 100));
query.limit(limit);
query.skip(skip);
if (sort)
query.sort(sort);
query.fields(["name", "fobCurrency", "fobPriceMin", "fobPriceMax", "fobUnit", "mainPicture", "minOrderQuan", "minOrderUnit"]);
ottoman.bucket.query(query, (error, result, meta) => {
if (error) {
reject(error);
}
else {
var resultset = {
hits: result,
totalHits: meta.totalHits
};
resolve(resultset);
}
});
}.bind(this))
}
My test server has Intel® Xeon® Processor E7-4890 v2 2.80 GHz and 12 gb RAM. In single node if I use ‘Moss’ as index type my service can only respond 300 requests per second. If I changed the index type to ‘Scorch’ it’s increasing to 500-530 requests per second. I believe these are not very good results. What am i doing wrong? How can I increase the performance?