X-Git-Url: https://git.plutz.net//?a=blobdiff_plain;f=index.cgi;h=94c397041e73483d0db5bedaa5b88ab903070934;hb=1a3925fc31df0c8810d3a938e750ee2b2bf460df;hp=07cb6e336848aad523af54610fa5c824e9866b71;hpb=e5cdcfedb1297430241508264e338c7c1b5a3f0f;p=rigidfind diff --git a/index.cgi b/index.cgi index 07cb6e3..94c3970 100755 --- a/index.cgi +++ b/index.cgi @@ -1,11 +1,13 @@ #!/bin/sh +read _DATE _date_n <<-EOF + $(date +"%s %N") + EOF + . "${_EXEC:-${0%/*}}/cgilite/cgilite.sh" . "${_EXEC:-${0%/*}}/cgilite/storage.sh" . "${_EXEC:-${0%/*}}/cgilite/json.sh" -[ "$_DATE" ] || _DATE="$(date +%s)" - debug "$REQUEST_METHOD $REQUEST_URI $SERVER_PROTOCOL $_DATE" ingest() { @@ -217,7 +219,7 @@ elif [ "$REQUEST_METHOD" = "POST" ]; then words="$( for j in $(DB2 "$J" iterate @); do json_get "$(UNSTRING "$j")" match_phrase_prefix.content - done 2>/dev/null + done 2>/dev/null |tr \\n ' ' )" debug "Search words: $words" @@ -234,14 +236,15 @@ elif [ "$REQUEST_METHOD" = "POST" ]; then )" results="${results% }" + t="$(( ${_DATE}${_date_n} - $(date +%s%N) ))" + cat <<-EOF Status: 200 OK X-elastic-product: Elasticsearch Content-Type: application/vnd.elasticsearch+json;compatible-with=8 - { "took":0, + { "took":$((t / 1000)), "timed_out":false, - "_shards":{"total":1,"successful":1,"skipped":0,"failed":0}, "hits": { "total":{"value": $(DB2 "$results" count @) ,"relation":"eq"}, "max_score": $(json_get "arr:$results" '[0]._score' 2>/dev/null || printf 0),