I tried without sorting and the response is still around 2 seconds.
Below is an example document and how the query is made:
{
'id' => "123fd-fds45-fdt4-5435",
'pp' => "word1 word2, word3",
'np' => "word4 word5",
'cd' => 167322240,
'pv' => 7,
'nv' => 1,
'dl' => 3,
'iw' => 512,
'ih' => 512,
'mi' => 4,
'st' =>true,
'ii' => "asd-asd-fdsf-fgdfg-gfd",
'm' => array(
't' => 'fts',
'it' => unixtimestamp
'v' => 4 #version
)
}
the query is a conjunction of
MatchPhraseSearchQuery for the fields pp
and np
NumericRangeSearchQuery for the fields mi
,nv
,iw
,ih
MatchSearchQuery for the fields ii
and im
the sort is: '-_score', '-pv', '+nv', '-dl', 'cd'
there is a limit
of 10 results and on offest
which could go up to 300
the index defintion is like this:
{
"name": "image_prompt_fts-v2",
"type": "fulltext-index",
"params": {
"doc_config": {
"docid_prefix_delim": "",
"docid_regexp": "",
"mode": "type_field",
"type_field": "m.t"
},
"mapping": {
"default_analyzer": "en",
"default_datetime_parser": "dateTimeOptional",
"default_field": "_all",
"default_mapping": {
"dynamic": true,
"enabled": false
},
"default_type": "_default",
"docvalues_dynamic": false,
"index_dynamic": false,
"store_dynamic": false,
"type_field": "_type",
"types": {
"fts": {
"dynamic": false,
"enabled": true,
"properties": {
"cd": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "cd",
"type": "number"
}
]
},
"dl": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "dl",
"type": "number"
}
]
},
"ih": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "ih",
"type": "number"
}
]
},
"ii": {
"enabled": true,
"dynamic": false,
"fields": [
{
"analyzer": "keyword",
"index": true,
"name": "ii",
"type": "text"
}
]
},
"im": {
"enabled": true,
"dynamic": false,
"fields": [
{
"analyzer": "keyword",
"index": true,
"name": "im",
"type": "text"
}
]
},
"iw": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "iw",
"type": "number"
}
]
},
"mi": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "mi",
"type": "number"
}
]
},
"mt": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "mt",
"store": true,
"type": "number"
}
]
},
"np": {
"enabled": true,
"dynamic": false,
"fields": [
{
"analyzer": "en",
"include_term_vectors": true,
"index": true,
"name": "np",
"type": "text"
}
]
},
"nv": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "nv",
"type": "number"
}
]
},
"pi": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "pi",
"store": true,
"type": "boolean"
}
]
},
"pp": {
"enabled": true,
"dynamic": false,
"fields": [
{
"analyzer": "en",
"include_term_vectors": true,
"index": true,
"name": "pp",
"type": "text"
}
]
},
"pv": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "pv",
"type": "number"
}
]
},
"s": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "s",
"type": "number"
}
]
},
"st": {
"enabled": true,
"dynamic": false,
"fields": [
{
"index": true,
"name": "st",
"type": "boolean"
}
]
}
}
}
}
},
"store": {
"indexType": "scorch",
"segmentVersion": 15
}
},
"sourceType": "gocbcore",
"sourceName": "images_fts",
"sourceUUID": "808e0bb49eb0ae702ced856f2824d649",
"sourceParams": {},
"planParams": {
"maxPartitionsPerPIndex": 342,
"indexPartitions": 3,
"numReplicas": 0
},
"uuid": "163a5123f8ba96bf"
}
search index stats looks like this:
as an example without any sort:
and the servers load is around 2%
FTS ram used by the index is around 30GB per server and allocated is around 72GB per server