Using conversational agents for agentic search
출처: 문서
본문
컨버세이셔널 에이전트를 활용한 에이전틱 검색
컨버세이셔널 에이전트는 상세한 추론 과정과 대화 메모리를 갖춘 고급 에이전틱 검색 기능을 제공해요. 도구를 순차적으로 실행하고 생성된 도메인 특화 언어(DSL) 쿼리만 반환하는 플로우 에이전트와 달리, 컨버세이셔널 에이전트는 agentic_context 응답 프로세서를 통해 단계별 추론 요약과 여러 쿼리에 걸쳐 대화를 이어갈 수 있는 메모리 ID를 포함한 추가 컨텍스트를 제공해요.
이 가이드에서는 여러 도구를 갖춘 컨버세이셔널 에이전트를 구성하는 방법과, 복잡한 검색 시나리오에서 고급 기능을 활용하는 방법을 살펴봐요.
컨버세이셔널 에이전트로 에이전틱 검색을 구성하는 방법은 두 가지가 있어요:
- 자동화 워크플로 (빠른 설정에 권장): 단일 API 호출로 인덱스를 제외한 모든 에이전틱 검색 리소스를 자동으로 생성해요.
- 수동 설정 (커스텀 구성에 권장): 더 큰 유연성과 제어력을 위해 각 컴포넌트를 직접 구성해요.
자동화 워크플로
OpenSearch는 Amazon Bedrock 커넥터, 원격 채팅 모델, QueryPlanningTool, ListIndexTool, IndexMappingTool, 대화 메모리를 갖춘 컨버세이셔널 에이전트, 그리고 검색 파이프라인을 자동으로 생성하는 워크플로 템플릿을 제공해요. 워크플로 템플릿 기본값을 검토해서 파라미터를 업데이트해야 하는지 확인해 보세요. 컨버세이셔널 에이전트가 포함된 기본 에이전틱 검색 워크플로를 생성하려면 다음 요청을 보내세요:
POST /_plugins/_flow_framework/workflow?use_case=agentic_search_with_conversational_agent&provision=true
{
"create_connector.credential.access_key": "<your-aws-access-key>",
"create_connector.credential.secret_key": "<your-aws-secret-key>",
"create_connector.credential.session_token": "<your-aws-session-token>"
}
{% include copy-curl.html %}
OpenSearch는 생성된 워크플로의 워크플로 ID를 응답으로 반환해요:
{
"workflow_id" : "abc123"
}
워크플로 상태를 확인하려면 다음 요청을 보내세요:
GET /_plugins/_flow_framework/workflow/abc123/_status
{% include copy-curl.html %}
워크플로가 완료되면 state가 COMPLETED로 바뀌어요. 이 워크플로는 에이전틱 검색 리소스를 생성하지만 인덱스는 생성하지 않아요. 프로비저닝된 검색 파이프라인을 사용해 기존 인덱스를 쿼리할 수 있어요. 예시 쿼리는 6단계를 참고하세요.
수동 설정
다음 단계에 따라 에이전틱 컨버스 플로우를 수동으로 설정하세요.
1단계: 제품 인덱스 생성
이름, 가격, 색상, 카테고리 같은 다양한 속성을 포함하는 제품 데이터로 샘플 인덱스를 생성하세요:
PUT /products-index
{
"settings": {
"number_of_shards": "4",
"number_of_replicas": "2"
},
"mappings": {
"properties": {
"product_name": { "type": "text" },
"description": { "type": "text" },
"price": { "type": "float" },
"currency": { "type": "keyword" },
"rating": { "type": "float" },
"review_count": { "type": "integer" },
"in_stock": { "type": "boolean" },
"color": { "type": "keyword" },
"size": { "type": "keyword" },
"category": { "type": "keyword" },
"brand": { "type": "keyword" },
"tags": { "type": "keyword" }
}
}
}
{% include copy-curl.html %}
2단계: 샘플 데이터 색인
인덱스에 샘플 제품 문서를 추가하세요:
POST _bulk
{ "index": { "_index": "products-index", "_id": "1" } }
{ "product_name": "Nike Air Max 270", "description": "Comfortable running shoes with Air Max technology", "price": 150.0, "currency": "USD", "rating": 4.5, "review_count": 1200, "in_stock": true, "color": "white", "size": "10", "category": "shoes", "brand": "Nike", "tags": ["running", "athletic", "comfortable"] }
{ "index": { "_index": "products-index", "_id": "2" } }
{ "product_name": "Adidas Ultraboost 22", "description": "Premium running shoes with Boost midsole", "price": 180.0, "currency": "USD", "rating": 4.7, "review_count": 850, "in_stock": true, "color": "black", "size": "9", "category": "shoes", "brand": "Adidas", "tags": ["running", "premium", "boost"] }
{ "index": { "_index": "products-index", "_id": "3" } }
{ "product_name": "Converse Chuck Taylor", "description": "Classic canvas sneakers", "price": 65.0, "currency": "USD", "rating": 4.2, "review_count": 2100, "in_stock": true, "color": "white", "size": "8", "category": "shoes", "brand": "Converse", "tags": ["casual", "classic", "canvas"] }
{ "index": { "_index": "products-index", "_id": "4" } }
{ "product_name": "Puma RS-X", "description": "Retro-inspired running shoes with modern comfort", "price": 120.0, "currency": "USD", "rating": 4.3, "review_count": 750, "in_stock": true, "color": "black", "size": "9", "category": "shoes", "brand": "Puma", "tags": ["retro", "running", "comfortable"] }
{% include copy-curl.html %}
3단계: 모델 생성
모델 구성을 검토하고 사용할 모델을 선택하세요.
다음 예시는 컨버세이셔널 에이전트와 QueryPlanningTool이 모두 사용하게 될 GPT 모델을 등록해요:
POST /_plugins/_ml/models/_register
{
"name": "My OpenAI model: gpt-5",
"function_name": "remote",
"description": "test model",
"connector": {
"name": "My openai connector: gpt-5",
"description": "The connector to openai chat model",
"version": 1,
"protocol": "http",
"parameters": {
"model": "gpt-5"
},
"credential": {
"openAI_key": "your-openai-api-key"
},
"actions": [
{
"action_type": "predict",
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions",
"headers": {
"Authorization": "Bearer ${credential.openAI_key}"
},
"request_body": "{ \"model\": \"${parameters.model}\", \"messages\": [{\"role\":\"developer\",\"content\":\"${parameters.system_prompt}\"},${parameters._chat_history:-}{\"role\":\"user\",\"content\":\"${parameters.user_prompt}\"}${parameters._interactions:-}], \"reasoning_effort\":\"low\"${parameters.tool_configs:-}}"
}
]
}
}
{% include copy-curl.html %}
4단계: 에이전트 등록
여러 도구를 갖춘 컨버세이셔널 에이전트를 등록해요---사용 가능한 인덱스를 탐색하는 ListIndexTool, 인덱스 구조를 파악하는 IndexMappingTool, 외부 데이터 접근을 위한 WebSearchTool, 그리고 OpenSearch DSL을 생성하는 필수 도구인 QueryPlanningTool이에요.
기본 구성은 에이전틱 검색 에이전트 구성을 참고하세요. 에이전트에는 QueryPlanningTool이 반드시 포함되어야 해요:
POST /_plugins/_ml/agents/_register
{
"name": "E-commerce Search Agent",
"type": "conversational",
"description": "Intelligent e-commerce search with product discovery",
"llm": {
"model_id": "your-model-id",
"parameters": {
"max_iteration": 20
}
},
"memory": {
"type": "conversation_index"
},
"parameters": {
"_llm_interface": "openai/v1/chat/completions"
},
"tools": [
{
"type": "ListIndexTool",
"name": "ListIndexTool"
},
{
"type": "IndexMappingTool",
"name": "IndexMappingTool"
},
{
"type": "WebSearchTool",
"parameters": {
"engine": "duckduckgo"
}
},
{
"type": "QueryPlanningTool"
}
],
"app_type": "os_chat"
}
{% include copy-curl.html %}
5단계: 검색 파이프라인 구성
요청 프로세서와 응답 프로세서를 모두 갖춘 검색 파이프라인을 생성하세요. agentic_query_translator 요청 프로세서는 자연어 쿼리를 OpenSearch DSL로 변환하고, agentic_context 응답 프로세서는 모니터링과 대화 연속성을 위한 에이전트 실행 컨텍스트 정보를 추가해요:
PUT _search/pipeline/agentic-pipeline
{
"request_processors": [
{
"agentic_query_translator": {
"agent_id": "your-ecommerce-agent-id"
}
}
],
"response_processors": [
{
"agentic_context": {
"agent_steps_summary": true,
"dsl_query": true
}
}
]
}
{% include copy-curl.html %}
6단계: 에이전틱 검색 실행
검색을 실행하려면 자연어 검색 쿼리를 보내세요. 에이전트가 요청을 분석하고, 적절한 인덱스를 찾아내고, 최적화된 DSL 쿼리를 생성해요:
GET /_search?search_pipeline=agentic-pipeline
{
"query": {
"agentic": {
"query_text": "Find me white shoes under 150 dollars"
}
}
}
{% include copy-curl.html %}
응답에는 일치하는 제품과 함께 ext 객체에 상세한 에이전트 정보가 담겨 있어서, 에이전트의 추론 과정과 생성된 DSL 쿼리를 확인할 수 있어요:
{
"took": 12146,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": null,
"hits": [
{
"_index": "products-index",
"_id": "3",
"_score": 0.0,
"_source": {
"product_name": "Converse Chuck Taylor",
"description": "Classic canvas sneakers",
"price": 65.0,
"currency": "USD",
"rating": 4.2,
"review_count": 2100,
"in_stock": true,
"color": "white",
"size": "8",
"category": "shoes",
"brand": "Converse",
"tags": [
"casual",
"classic",
"canvas"
]
},
"sort": [
65.0,
0.0
]
},
{
"_index": "products-index",
"_id": "1",
"_score": 0.0,
"_source": {
"product_name": "Nike Air Max 270",
"description": "Comfortable running shoes with Air Max technology",
"price": 150.0,
"currency": "USD",
"rating": 4.5,
"review_count": 1200,
"in_stock": true,
"color": "white",
"size": "10",
"category": "shoes",
"brand": "Nike",
"tags": [
"running",
"athletic",
"comfortable"
]
},
"sort": [
150.0,
0.0
]
}
]
},
"ext": {
"agent_steps_summary": "I have these tools available: [ListIndexTool, IndexMappingTool, query_planner_tool]\nFirst I used: ListIndexTool — input: \"[]\"; context gained: \"Found indices; 'products-index' appears most relevant for product queries\"\nSecond I used: query_planner_tool — qpt.question: \"Find white shoes under 150 dollars.\"; index_name_provided: \"products-index\"\nThird I used: query_planner_tool — qpt.question: \"Find white shoes priced under 150 dollars.\"; index_name_provided: \"products-index\"\nValidation: qpt output is valid JSON and aligns with the request for white shoes under 150 dollars in the products-index.",
"memory_id": "XRzFl5kB-5P992SCeeqO",
"dsl_query": "{\"size\":10.0,\"query\":{\"bool\":{\"filter\":[{\"term\":{\"category\":\"shoes\"}},{\"term\":{\"color\":\"white\"}},{\"range\":{\"price\":{\"lte\":150.0}}}]}},\"sort\":[{\"price\":{\"order\":\"asc\"}},{\"_score\":{\"order\":\"desc\"}}]}"
}
}
7단계: 메모리 ID로 에이전틱 검색 실행
이전 응답에서 받은 memory_id를 사용해 후속 쿼리를 보내세요:
GET /_search?search_pipeline=agentic-pipeline
{
"query": {
"agentic": {
"query_text": "Actually, show black ones instead",
"memory_id": "<memory_id from previous response>"
}
}
}
{% include copy-curl.html %}
에이전트는 컨텍스트를 기억하고 새 요청에 적용해요. "black ones instead"를 성공적으로 해석하고, 이전 컨텍스트의 $150 예산도 그대로 유지해요:
{
"took": 8942,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": null,
"hits": [
{
"_index": "products-index",
"_id": "4",
"_score": 0.0,
"_source": {
"product_name": "Puma RS-X",
"description": "Retro-inspired running shoes with modern comfort",
"price": 120.0,
"currency": "USD",
"rating": 4.3,
"review_count": 750,
"in_stock": true,
"color": "black",
"size": "9",
"category": "shoes",
"brand": "Puma",
"tags": [
"retro",
"running",
"comfortable"
]
},
"sort": [
120.0,
0.0
]
}
]
},
"ext": {
"agent_steps_summary": "I have these tools available: [ListIndexTool, IndexMappingTool, query_planner_tool]\nFirst I used: query_planner_tool — qpt.question: \"Find black shoes priced under 150 dollars.\"; index_name_provided: \"products-index\"\nValidation: qpt output is valid JSON and aligns with the request for black shoes under 150 dollars in the products-index.",
"memory_id": "XRzFl5kB-5P992SCeeqO",
"dsl_query": "{\"size\":10.0,\"query\":{\"bool\":{\"filter\":[{\"term\":{\"category\":\"shoes\"}},{\"term\":{\"color\":\"black\"}},{\"range\":{\"price\":{\"lte\":150.0}}}]}},\"sort\":[{\"price\":{\"order\":\"asc\"}},{\"_score\":{\"order\":\"desc\"}}]}"
}
}
힌트를 사용해 LLM 유도하기
query_text에 힌트를 제공하면 대규모 언어 모델(LLM)이 여러분이 원하는 DSL 쿼리를 생성하도록 유도할 수 있어요. 에이전트는 검색을 계획할 때 이 힌트들을 고려해요.
다음 쿼리는 에이전트의 DSL 생성을 유도하기 위해 정렬과 애그리게이션에 대한 구체적인 힌트를 제공해요:
GET /_search?search_pipeline=agentic-pipeline
{
"query": {
"agentic": {
"query_text": "Find expensive running shoes, sort by rating descending, and use aggregations to show average price by brand"
}
}
}
{% include copy-curl.html %}
반면 다음 쿼리는 구체적인 DSL 힌트 없이 단순한 표현을 사용해요:
GET /_search?search_pipeline=agentic-pipeline
{
"query": {
"agentic": {
"query_text": "Show me running shoes"
}
}
}
{% include copy-curl.html %}
첫 번째 쿼리는 정렬과 애그리게이션이 포함된 더 복잡한 DSL을 생성할 가능성이 높고, 두 번째 쿼리는 더 단순한 DSL이 생성될 거예요. "sort by", "aggregate", "filter by", "group by" 같은 구체적인 표현을 사용해서 에이전트의 쿼리 생성을 유도하세요.
다음 단계
- 에이전틱 쿼리 트랜슬레이터 프로세서 -- 자연어 쿼리를 OpenSearch DSL로 변환하는 요청 프로세서에 대해 자세히 알아보세요.
- 에이전틱 컨텍스트 프로세서 -- 모니터링과 대화 연속성을 위한 에이전트 실행 컨텍스트 정보를 추가하는 응답 프로세서에 대해 자세히 알아보세요.
- 에이전틱 검색 에이전트 구성 -- 다양한 모델, 도구, 프롬프트로 에이전트 동작을 구성해 보세요.