Higress supports enhancing the accuracy and timeliness of responses from models like DeepSeek-R1 by integrating real-time results from search engines (Google/Bing/Arxiv/Elasticsearch etc.)
Feature Description
The ai-search plugin enhances the accuracy and timeliness of AI model responses by integrating real-time results from search engines (Google/Bing/Arxiv/Elasticsearch etc.). The plugin automatically injects search results into the prompt template and determines whether to add reference sources in the final response based on configuration.
Reference content format, must include %s placeholder
defaultLang
string
Optional
-
Default search language code (e.g. zh-CN/en-US)
promptTemplate
string
Optional
Built-in template
Prompt template, must include {search_results} and {question} placeholders
searchFrom
array of object
Required
-
Refer to search engine configuration below, at least one engine must be configured
searchRewrite
object
Optional
-
Search rewrite configuration, used to optimize search queries using an LLM service
Search Rewrite Description
The search rewrite feature uses an LLM service to analyze and optimize the user's original query, which can:
Convert natural language queries into keyword combinations better suited for search engines
For Arxiv paper searches, automatically identify relevant paper categories and add category constraints
For private knowledge base searches, break down long queries into multiple precise keyword combinations
It is strongly recommended to enable this feature when using Arxiv or Elasticsearch engines. For Arxiv searches, it can accurately identify paper domains and optimize English keywords; for private knowledge base searches, it can provide more precise keyword matching, significantly improving search effectiveness.
Search Rewrite Configuration
Name
Data Type
Requirement
Default Value
Description
llmServiceName
string
Required
-
LLM service name
llmServicePort
number
Required
-
LLM service port
llmApiKey
string
Required
-
LLM service API key
llmUrl
string
Required
-
LLM service API URL
llmModelName
string
Required
-
LLM model name
timeoutMillisecond
number
Optional
30000
API call timeout (milliseconds)
Search Engine Common Configuration
Name
Data Type
Requirement
Default Value
Description
type
string
Required
-
Engine type (google/bing/arxiv/elasticsearch)
apiKey
string
Required
-
Search engine API key
serviceName
string
Required
-
Backend service name
servicePort
number
Required
-
Backend service port
count
number
Optional
10
Number of results returned per search
start
number
Optional
0
Search result offset (start returning from the start+1 result)
timeoutMillisecond
number
Optional
5000
API call timeout (milliseconds)
optionArgs
map
Optional
-
Search engine specific parameters (key-value format)
Google Specific Configuration
Name
Data Type
Requirement
Default Value
Description
cx
string
Required
-
Google Custom Search Engine ID, used to specify search scope
defaultLang:"en-US"promptTemplate:| # Search Results:
{search_results}
# Please answer this question:
{question}searchFrom:- type:googleapiKey:"google-key"cx:"github-search-id"# Search engine ID specifically for GitHub contentserviceName:"google-svc.dns"servicePort:443- type:googleapiKey:"google-key"cx:"news-search-id"# Search engine ID specifically for Google News content serviceName:"google-svc.dns"servicePort:443- type:bingapiKey:"bing-key"serviceName:"bing-svc.dns"servicePort:443optionArgs:answerCount:"5"
Concurrent Query Configuration
Since search engines limit the number of results per query (e.g. Google limits to 100 results per query), you can get more results by:
Setting a smaller count value (e.g. 10)
Specifying result offset with start parameter
Concurrently initiating multiple query requests, with each request's start value incrementing by count
For example, to get 30 results, configure count=10 and concurrently initiate 3 queries with start values 0,10,20 respectively:
Note that excessive concurrency may lead to rate limiting, adjust according to actual situation.
Elasticsearch Configuration (For Private Knowledge Base Integration)
searchFrom:- type:elasticsearchserviceName:"es-svc.static"# static ip service use 80 as default portservicePort:80index:"knowledge_base"contentField:"content"linkField:"url"titleField:"title"
Custom Reference Format
needReference:truereferenceFormat:"### Data Sources\n%s"searchFrom:- type:bingapiKey:"your-bing-key"serviceName:"search-service.dns"servicePort:8080
The prompt template must include {search_results} and {question} placeholders, optionally use {cur_date} to insert current date (format: January 2, 2006)
The default template includes search results processing instructions and response specifications, you can use the default template unless there are special needs
Multiple search engines query in parallel, total timeout = maximum timeoutMillisecond value among all search engine configurations + processing time
Arxiv search doesn't require API key, but you can specify paper category (arxivCategory) to narrow search scope