conversations
listlengths
3
3
metadata
dict
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"IT Security Policy – Remote Access\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-02-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"access\",\n \"security\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Patient Data Confidentiality Guidelines\",\n \"author\": \"Dr. Bob Lee\",\n \"department\": \"Compliance\",\n \"createdAt\": \"2022-11-30\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"confidentiality\",\n \"patient\",\n \"data\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Finance Department Budget Report 2024\",\n \"author\": \"Carol Nguyen\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-10\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"budget\",\n \"2024\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"IT Security Incident Response Procedure\",\n \"author\": \"David Patel\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-07-22\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"Medical Equipment Maintenance Log\",\n \"author\": \"Emily Zhao\",\n \"department\": \"Biomedical Engineering\",\n \"createdAt\": \"2024-03-05\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"log\",\n \"tags\": [\n \"maintenance\",\n \"equipment\"\n ],\n \"confidentialityLevel\": \"low\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent policy documents\",\n \"dsl_type\": \"simple_match\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match\": {\n \"category\": \"policy\"\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 33 approved PDF policies from IT Security department created after 2023-01-01\n\nRephrased Query: Retrieve 33 approved PDF policy documents from the IT Security department with creation date after 2023-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 33,\n \"from\": 33,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"match\": {\n \"category\": \"policy\"\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"match_phrase\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2023-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "pagination", "pattern_type": "more_results", "size": 33, "from": 33, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Academic Articles - Policy Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Approved Policy on Data Encryption\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"security\",\n \"tags\": [\n \"encryption\",\n \"data-protection\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Department Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-05-10T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote-work\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"HR Approved Policy on Employee Benefits\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-20T08:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"benefits\",\n \"tags\": [\n \"health\",\n \"vacation\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"IT Security Incident Response Procedure\",\n \"author\": \"david.kim\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-05T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident-response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Finance Approved Policy on Expense Reporting\",\n \"author\": \"emma.wilson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-03-22T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"finance\",\n \"tags\": [\n \"expenses\",\n \"reporting\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List approved policies from IT Security\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"match\": {\n \"title\": \"policy\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"match\": {\n \"title\": \"policy\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Academic Articles - Policy Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "listing_with_filters", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P1001\",\n \"title\": \"Enterprise Network Router\",\n \"description\": \"High‑performance router for enterprise networks with advanced security features.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 1299.99\n },\n {\n \"productId\": \"P1002\",\n \"title\": \"Wireless Access Point\",\n \"description\": \"Dual‑band access point supporting up to 500 users.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"network\",\n \"assignee\": \"field_engineer\",\n \"createdAt\": \"2024-08-05T14:22:10Z\",\n \"price\": 299.5\n },\n {\n \"productId\": \"P1003\",\n \"title\": \"Server Rack Mount Kit\",\n \"description\": \"Standard 19‑inch rack mount kit for server hardware.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"logistics\",\n \"createdAt\": \"2024-07-20T10:05:45Z\",\n \"price\": 89\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show open tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high‑priority tickets assigned to tech support\n\nRephrased Query: List open tickets with high priority that are assigned to tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SC-1001\",\n \"title\": \"Annual Supply Agreement for Office Supplies\",\n \"description\": \"Contract with ABC Supplies covering paper, pens, and toner for FY2025.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"procurement\",\n \"assignee\": \"jane.doe\",\n \"createdAt\": \"2024-09-12T08:30:00Z\",\n \"price\": 12500\n },\n {\n \"ticketId\": \"SC-1002\",\n \"title\": \"Hardware Maintenance Contract\",\n \"description\": \"Three‑year maintenance agreement for server hardware with TechServe Ltd.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"maintenance\",\n \"assignee\": \"john.smith\",\n \"createdAt\": \"2023-05-20T14:15:00Z\",\n \"price\": 48000\n },\n {\n \"ticketId\": \"SC-1003\",\n \"title\": \"Network Services SLA\",\n \"description\": \"Service level agreement for network monitoring and support with NetGuard Inc.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"network\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2024-01-03T10:45:00Z\",\n \"price\": 30000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving all open tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List all tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P1001\",\n \"title\": \"Wireless Mouse\",\n \"description\": \"Ergonomic wireless mouse with adjustable DPI.\",\n \"status\": \"available\",\n \"priority\": \"low\",\n \"category\": \"electronics\",\n \"assignee\": \"inventory_team\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 29.99,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P1002\",\n \"title\": \"Gaming Laptop\",\n \"description\": \"High-performance laptop with RTX graphics and 16GB RAM.\",\n \"status\": \"out_of_stock\",\n \"priority\": \"high\",\n \"category\": \"computers\",\n \"assignee\": \"sales_team\",\n \"createdAt\": \"2024-08-05T14:22:10Z\",\n \"price\": 1499,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P1003\",\n \"title\": \"Bluetooth Headphones\",\n \"description\": \"Noise-cancelling over-ear headphones with 20h battery life.\",\n \"status\": \"available\",\n \"priority\": \"medium\",\n \"category\": \"audio\",\n \"assignee\": \"support_team\",\n \"createdAt\": \"2024-07-20T10:05:45Z\",\n \"price\": 89.5,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the latest tickets from the catalog.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing", "pattern": "refinement", "pattern_type": "narrow_scope", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Approved Policy\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"access\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"review\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-12-01T08:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policy documents belonging to the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Project Management Tasks\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Investigate and resolve high latency on the corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"alice\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Quarterly budget review\",\n \"description\": \"Prepare and present the Q4 budget for the finance department.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"finance\",\n \"assignee\": \"bob\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"UI redesign for dashboard\",\n \"description\": \"Create new mockups and implement the updated UI for the analytics dashboard.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"design\",\n \"assignee\": \"carol\",\n \"createdAt\": \"2025-08-05T11:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets assigned to Alice\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the open tickets that are currently assigned to Alice.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets assigned to Alice\n\nRephrased Query: List tickets where status is open and assignee is Alice\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"alice\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Project Management Tasks", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Project Management Tasks\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n },\n \"documentContentWords\": {\n \"type\": \"text\"\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue on branch office\",\n \"description\": \"Users report intermittent latency when accessing internal services.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Upgrade database server RAM\",\n \"description\": \"Current RAM insufficient for peak loads; plan upgrade to 64GB.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"infrastructure\",\n \"assignee\": \"devops\",\n \"createdAt\": \"2024-09-28T14:42:10Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Finalize Q4 budget report\",\n \"description\": \"Compile all department expenses and submit for approval.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"finance\",\n \"assignee\": \"accounting\",\n \"createdAt\": \"2024-08-05T09:00:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent tickets sorted by creation date.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List 65 high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 65 tickets where priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 65,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n },\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Project Management Tasks", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 65, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TCKT-001\",\n \"title\": \"Invoice discrepancy for client XYZ\",\n \"author\": \"alice.smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"billing\",\n \"tags\": [\n \"invoice\",\n \"discrepancy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"Password reset request\",\n \"author\": \"bob.jones\",\n \"department\": \"IT Support\",\n \"createdAt\": \"2024-03-01T14:12:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"closed\",\n \"category\": \"access\",\n \"tags\": [\n \"password\",\n \"reset\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Request for new workstation\",\n \"author\": \"carol.lee\",\n \"department\": \"Engineering\",\n \"createdAt\": \"2024-01-20T11:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"in_progress\",\n \"category\": \"hardware\",\n \"tags\": [\n \"workstation\",\n \"procurement\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-004\",\n \"title\": \"Annual security policy update\",\n \"author\": \"david.khan\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-04-05T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"annual\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCKT-005\",\n \"title\": \"Travel expense reimbursement\",\n \"author\": \"emma.wong\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-28T16:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"expense\",\n \"tags\": [\n \"travel\",\n \"reimbursement\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the open tickets from Finance after January 2024?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve tickets with status 'open', department 'Finance', and created after 2024-01-01.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show closed tickets from IT Support\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0\n ],\n \"k\": 10\n },\n \"text\": {\n \"field\": \"title\",\n \"query\": \"closed tickets\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"closed\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Support\"\n }\n }\n ]\n }\n }\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: List open tickets from Finance department after 2024-01-01\n\nRephrased Query: Retrieve tickets where status is 'open', department is 'Finance', and createdAt is greater than 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0\n ],\n \"k\": 10\n },\n \"text\": {\n \"field\": \"title\",\n \"query\": \"open tickets\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experience high latency on the corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal of Adobe Creative Cloud licenses for design team.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-12T14:42:10Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Defective printer\",\n \"description\": \"Office printer model X123 is printing blank pages.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"facility team\",\n \"createdAt\": \"2025-10-05T09:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-004\",\n \"title\": \"Account access request\",\n \"description\": \"New employee needs access to the finance system.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"account\",\n \"assignee\": \"it admin\",\n \"createdAt\": \"2025-10-18T11:20:45Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-005\",\n \"title\": \"Website downtime\",\n \"description\": \"Public website is down due to server overload.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-22T03:05:12Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority tickets assigned to tech support\n\nRephrased Query: List open tickets with high priority assigned to tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Research Papers\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"IT Security\",\n \"tags\": [\n \"policy\",\n \"security\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-02-20T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"HR Policies\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Financial Reporting Standards 2024\",\n \"author\": \"carla.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-05T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Finance\",\n \"tags\": [\n \"reporting\",\n \"standards\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List PDFs from Finance department after 2024\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the requested documents...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n },\n \"text\": {\n \"field\": \"title\",\n \"query\": \"Finance PDF\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: Retrieve approved policy documents in the IT Security category\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n },\n \"text\": {\n \"field\": \"title\",\n \"query\": \"approved policies\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Research Papers", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"MKT-001\",\n \"title\": \"Launch Summer Promo Campaign\",\n \"description\": \"Create assets and schedule posts for the summer promotion.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-09-15T08:30:00Z\",\n \"price\": 1500\n },\n {\n \"ticketId\": \"MKT-002\",\n \"title\": \"Email Newsletter Q4\",\n \"description\": \"Design and send the Q4 newsletter to the subscriber list.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"content team\",\n \"createdAt\": \"2024-10-01T10:00:00Z\",\n \"price\": 800\n },\n {\n \"ticketId\": \"MKT-003\",\n \"title\": \"Social Media Analytics Review\",\n \"description\": \"Analyze performance metrics for the last month.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"analytics\",\n \"assignee\": \"data analyst\",\n \"createdAt\": \"2024-08-20T14:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me 10 tickets from the marketing index.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here is a DSL that returns the first 10 tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 tickets from the marketing index.\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show me 20 open high-priority network tickets assigned to tech support\n\nRephrased Query: List 20 tickets where status is open, priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 20,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 20, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"User reports intermittent latency on corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Billing discrepancy\",\n \"description\": \"Invoice shows extra charges for last month.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"account\",\n \"assignee\": \"billing_team\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software installation failure\",\n \"description\": \"Installation of CRM software fails with error code 0x80070005.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"software\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-11-01T11:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show all tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here is a list of all tickets in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve tickets where priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: financial_transactions\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Payment reversal request\",\n \"description\": \"Customer requested reversal of a $2,500 transaction due to duplicate charge.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"payment\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-10-28T09:15:30Z\",\n \"price\": 2500,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Fraudulent activity alert\",\n \"description\": \"Suspicious login from unknown IP resulting in unauthorized transfer of $7,800.\",\n \"status\": \"investigating\",\n \"priority\": \"critical\",\n \"category\": \"security\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2025-10-27T14:42:10Z\",\n \"price\": 7800,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Monthly statement generation delay\",\n \"description\": \"User reports that the March statement has not been generated yet.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"account\",\n \"assignee\": \"mike.lee\",\n \"createdAt\": \"2025-10-26T08:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the most recent tickets from the financial transactions index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List recent tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "financial_transactions", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TCKT-001\",\n \"title\": \"Unable to access VPN\",\n \"author\": \"alice.smith\",\n \"department\": \"IT\",\n \"createdAt\": \"2024-03-12T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"network\",\n \"tags\": [\n \"vpn\",\n \"access\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"Payroll discrepancy for March\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-28T14:40:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"payroll\",\n \"tags\": [\n \"salary\",\n \"march\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Request for new laptop\",\n \"author\": \"carol.lee\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-01-05T11:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"closed\",\n \"category\": \"hardware\",\n \"tags\": [\n \"laptop\",\n \"request\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 10 tickets from the Finance department.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the 10 most recent tickets from Finance.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 tickets from the Finance department.\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List 15 approved tickets from IT department after 2023-01-01\n\nRephrased Query: Retrieve the latest 15 tickets with status approved, department IT, created after 2023-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 15,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2023-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "previous_page", "size": 15, "from": 0, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Quarterly Security Policy Update\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"quarterly\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-01-10T14:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Finance Department Budget Report 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-28T11:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"budget\",\n \"2024\",\n \"finance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"IT Security Incident Response Procedure\",\n \"author\": \"dave.kumar\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-12-05T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Find documents about remote work\",\n \"dsl_type\": \"semantic_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"semantic\": {\n \"field\": \"title\",\n \"model_id\": \"my-semantic-model\",\n \"query\": \"remote work\"\n }\n }\n }\n }\n]\n\nUser Query: Show approved posts from IT Security\n\nRephrased Query: List approved documents where department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"semantic\": {\n \"field\": \"title\",\n \"model_id\": \"my-semantic-model\",\n \"query\": \"approved\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "listing_with_filters", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-01-10T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-05T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Data Privacy Notice\",\n \"author\": \"dave.kumar\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-12-20T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"notice\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"eve.wang\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-22T16:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent documents\",\n \"dsl_type\": \"simple_match\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show 72 approved policies from IT Security department\n\nRephrased Query: Retrieve 72 approved policy documents belonging to the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 72,\n \"from\": 216,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"match\": {\n \"title\": \"policy\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "pagination", "pattern_type": "next_page", "size": 72, "from": 216, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TCKT-001\",\n \"title\": \"Invoice processing error\",\n \"author\": \"alice.smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2023-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"open\",\n \"category\": \"billing\",\n \"tags\": [\n \"invoice\",\n \"error\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"Access request for HR portal\",\n \"author\": \"bob.jones\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-03-01T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"closed\",\n \"category\": \"access\",\n \"tags\": [\n \"access\",\n \"hr\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"Server downtime investigation\",\n \"author\": \"carol.lee\",\n \"department\": \"IT\",\n \"createdAt\": \"2023-01-20T22:45:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"in_progress\",\n \"category\": \"infrastructure\",\n \"tags\": [\n \"downtime\",\n \"server\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me recent tickets from the IT department.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest tickets from IT.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me recent tickets from the IT department.\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"department.keyword\": \"IT\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List tickets from Finance department with status open after 2023-01-01\n\nRephrased Query: Retrieve up to 10 tickets where department is Finance, status is open, and createdAt is on or after 2023-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"department.keyword\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"status.keyword\": \"open\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2023-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: IT Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCKT-001\",\n \"title\": \"Network outage in building A\",\n \"description\": \"Users report loss of connectivity on floor 3.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-002\",\n \"title\": \"Software installation request\",\n \"description\": \"Install latest version of Photoshop for design team.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"app_admin\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-003\",\n \"title\": \"Printer malfunction on 2nd floor\",\n \"description\": \"Printer prints blank pages intermittently.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-05T10:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open high-priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the tickets that match your criteria.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all closed software tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"closed\"\n }\n },\n {\n \"term\": {\n \"category\": \"software\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve open tickets with high priority in the network category assigned to tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "IT Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Items\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"User reports intermittent latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"User reports intermittent latency on VPN connections.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Printer out of ink\",\n \"description\": \"Office printer in room 402 is out of cyan ink.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"facility_team\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Office printer in room 402 is out of cyan ink.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal needed for Adobe Creative Cloud for design team.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-11-01T09:05:45Z\",\n \"price\": 1200,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Renewal needed for Adobe Creative Cloud for design team.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Items", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experiencing high latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Printer malfunction\",\n \"description\": \"Office printer prints blank pages intermittently.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"maintenance\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal needed for design software for the marketing team.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-10-05T10:00:00Z\",\n \"price\": 1200\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open high-priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the requested tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all closed hardware tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"closed\"\n }\n },\n {\n \"term\": {\n \"category\": \"hardware\"\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve open tickets with high priority in the network category assigned to tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: product_reviews\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-20T08:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Product Review: Alpha Gadget\",\n \"author\": \"dave.kim\",\n \"department\": \"Product Management\",\n \"createdAt\": \"2024-01-10T12:45:00Z\",\n \"fileType\": \"txt\",\n \"status\": \"published\",\n \"category\": \"review\",\n \"tags\": [\n \"alpha\",\n \"gadget\",\n \"review\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"eve.wilson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-05T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policy documents from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [],\n \"k\": 10\n },\n \"text\": {\n \"multi_match\": {\n \"query\": \"finance pdf\",\n \"fields\": [\n \"title^3\",\n \"tags\",\n \"category\"\n ]\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: Retrieve all approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [],\n \"k\": 10\n },\n \"text\": {\n \"multi_match\": {\n \"query\": \"approved policy\",\n \"fields\": [\n \"title^3\",\n \"tags\",\n \"category\"\n ]\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "product_reviews", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Items\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"INV-1001\",\n \"title\": \"Router failure in Data Center\",\n \"description\": \"The core router experienced an unexpected shutdown causing network latency.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 1250\n },\n {\n \"ticketId\": \"INV-1002\",\n \"title\": \"Laptop battery replacement\",\n \"description\": \"Battery health below 20%, replacement required for employee laptop.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"it_ops\",\n \"createdAt\": \"2024-09-28T14:42:10Z\",\n \"price\": 150\n },\n {\n \"ticketId\": \"INV-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Annual renewal for design software licenses for the creative team.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2024-08-05T09:00:00Z\",\n \"price\": 3200\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List 19 high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 19 tickets where priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 19,\n \"from\": 57,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Items", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "specific_page", "size": 19, "from": 57, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"employeeId\": {\n \"type\": \"keyword\"\n },\n \"name\": {\n \"type\": \"text\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"hireDate\": {\n \"type\": \"date\"\n },\n \"salary\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"employeeId\": \"E001\",\n \"name\": \"Alice Johnson\",\n \"title\": \"Senior Software Engineer\",\n \"department\": \"Engineering\",\n \"status\": \"Active\",\n \"hireDate\": \"2018-04-12\",\n \"salary\": 115000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Alice has led multiple successful product releases.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"employeeId\": \"E002\",\n \"name\": \"Bob Martinez\",\n \"title\": \"HR Manager\",\n \"department\": \"Human Resources\",\n \"status\": \"Active\",\n \"hireDate\": \"2015-09-01\",\n \"salary\": 95000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Bob oversees recruitment and employee relations.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"employeeId\": \"E003\",\n \"name\": \"Carol Singh\",\n \"title\": \"Financial Analyst\",\n \"department\": \"Finance\",\n \"status\": \"On Leave\",\n \"hireDate\": \"2020-01-15\",\n \"salary\": 72000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Carol specializes in budgeting and forecasting.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the first 10 employee records?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here is a listing of the first 10 employee records.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 employee records\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show me 88 employee records\n\nRephrased Query: list 88 employee records without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 88,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"hireDate\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "keyword_search", "size": 88, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"User reports intermittent latency on corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Billing discrepancy\",\n \"description\": \"Invoice shows extra charges for last month.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"account\",\n \"assignee\": \"billing_team\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Password reset failure\",\n \"description\": \"Password reset email not received by user.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"authentication\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-11-01T09:05:45Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Software license renewal\",\n \"description\": \"Request to renew enterprise software license for Q4.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"license\",\n \"assignee\": \"account_manager\",\n \"createdAt\": \"2025-10-28T11:20:00Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"Server hardware upgrade\",\n \"description\": \"Upgrade RAM on server SRV-02 to improve performance.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"infrastructure\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-11-05T16:30:22Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the currently open tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all resolved tickets from March\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"resolved\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2025-03-01T00:00:00Z\",\n \"lt\": \"2025-04-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List open high priority tickets assigned to tech support\n\nRephrased Query: Retrieve open tickets with high priority that are assigned to the tech_support team\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"Patient Admission Guidelines\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Admissions\",\n \"createdAt\": \"2023-05-12T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"admission\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Radiology Safety Policies\",\n \"author\": \"Dr. Bob Lee\",\n \"department\": \"Radiology\",\n \"createdAt\": \"2024-01-20T14:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"safety\",\n \"radiology\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Pharmacy Drug Interaction Handbook\",\n \"author\": \"Dr. Carol Nguyen\",\n \"department\": \"Pharmacy\",\n \"createdAt\": \"2022-11-03T10:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"reference\",\n \"tags\": [\n \"drug\",\n \"interaction\"\n ],\n \"confidentialityLevel\": \"restricted\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List the latest approved policies from the Radiology department.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the approved Radiology policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List recent medical reports\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match\": {\n \"title\": {\n \"query\": \"medical report\",\n \"operator\": \"and\"\n }\n }\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies\n\nRephrased Query: List all approved policy documents\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match\": {\n \"title\": {\n \"query\": \"approved policy\",\n \"operator\": \"and\"\n }\n }\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ],\n \"minimum_should_match\": 1\n }\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"productId\": \"PRD-1001\",\n \"title\": \"Annual Supply Agreement for Widgets\",\n \"description\": \"Contract covering the supply of 10,000 widgets for FY2025.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"procurement\",\n \"assignee\": \"alice.smith\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 125000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"This agreement is made between Supplier Co. and Buyer Inc.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"Quarterly Maintenance Service Contract\",\n \"description\": \"Service contract for quarterly maintenance of production line equipment.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"services\",\n \"assignee\": \"bob.jones\",\n \"createdAt\": \"2024-06-03T14:42:10Z\",\n \"price\": 45000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The contractor shall perform maintenance every three months.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-003\",\n \"productId\": \"PRD-3003\",\n \"title\": \"One‑Year Software License Renewal\",\n \"description\": \"Renewal of software license for inventory management system.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"carol.lee\",\n \"createdAt\": \"2024-10-01T09:05:45Z\",\n \"price\": 22000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"License renewal extends usage rights for an additional twelve months.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the first 10 tickets from the Supplier Contracts index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List tickets without any filter or count specification\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 30,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing", "pattern": "pagination", "pattern_type": "next_page", "size": 10, "from": 30, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Corporate Policy Blog Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Approved Policy\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"access\",\n \"encryption\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Department Expense Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-10\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"expenses\",\n \"reimbursement\",\n \"budget\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Best Practices\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-05-01\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"productivity\",\n \"communication\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Data Retention Schedule\",\n \"author\": \"david.kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-20\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"retention\",\n \"archiving\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"eve.martin\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-12-05\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"mitigation\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the approved IT Security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"text\": {\n \"multi_match\": {\n \"query\": \"policy\",\n \"fields\": [\n \"title^3\",\n \"tags\",\n \"category\"\n ]\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: Retrieve PDF documents belonging to the Finance department that were created after January 1, 2024\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": {\n \"multi_match\": {\n \"query\": \"pdf\",\n \"fields\": [\n \"title^3\",\n \"tags\",\n \"category\"\n ]\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Corporate Policy Blog Posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: IT Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Cannot connect to VPN\",\n \"description\": \"User reports inability to establish VPN connection after password change.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Email delivery delay\",\n \"description\": \"Outgoing emails are delayed by up to 30 minutes.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"email team\",\n \"createdAt\": \"2025-10-18T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"License for design software expires next week.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-30T11:05:45Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Printer jam on floor 3\",\n \"description\": \"Laser printer constantly jams when printing large documents.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"hardware\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-22T09:27:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"Account locked after failed login attempts\",\n \"description\": \"User account locked after multiple failed password entries.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"account\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-21T16:33:20Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 24 high-priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the requested tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show 24 high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 24 tickets where status is open, priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 24,\n \"from\": 72,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "IT Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "more_results", "size": 24, "from": 72, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Policy – Access Control\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"access\",\n \"control\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Finance Department – Expense Reimbursement Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2023-11-20T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"expense\",\n \"reimbursement\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Remote Work Policy\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2024-01-10T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"flexibility\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-004\",\n \"title\": \"IT Security Policy – Data Encryption\",\n \"author\": \"david.kim\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-05T11:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"encryption\",\n \"data\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-005\",\n \"title\": \"Finance Audit Report Q1 2024\",\n \"author\": \"emma.wilson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-12T16:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"audit\",\n \"Q1\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0\n ],\n \"k\": 10\n }\n }\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security after 2024\n\nRephrased Query: List approved policy documents in the IT Security department created after January 1, 2024\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0\n ],\n \"k\": 10\n }\n }\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Items\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"productId\": \"PRD-2001\",\n \"title\": \"Network latency issue\",\n \"description\": \"User reports intermittent latency on corporate VPN.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"Printer malfunction\",\n \"description\": \"Laser printer in office 3B prints blank pages.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"maintenance\",\n \"createdAt\": \"2025-09-15T11:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"productId\": \"PRD-2003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renew annual license for design software.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-10-01T14:05:00Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"productId\": \"PRD-2004\",\n \"title\": \"Server disk space low\",\n \"description\": \"Primary DB server at 95% disk utilization.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"infrastructure\",\n \"assignee\": \"sysadmin\",\n \"createdAt\": \"2025-10-18T09:30:45Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"productId\": \"PRD-2005\",\n \"title\": \"Account access request\",\n \"description\": \"New employee needs access to CRM system.\",\n \"status\": \"pending\",\n \"priority\": \"medium\",\n \"category\": \"account\",\n \"assignee\": \"it support\",\n \"createdAt\": \"2025-10-12T16:20:15Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 20 open high-priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the first 20 tickets that match those criteria.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show 20 open high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve the first 20 tickets where status is open, priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 20,\n \"from\": 20,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Items", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "more_results", "size": 20, "from": 20, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"employeeId\": {\n \"type\": \"keyword\"\n },\n \"name\": {\n \"type\": \"text\"\n },\n \"position\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"seniority\": {\n \"type\": \"keyword\"\n },\n \"manager\": {\n \"type\": \"keyword\"\n },\n \"hireDate\": {\n \"type\": \"date\"\n },\n \"salary\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"employeeId\": \"E001\",\n \"name\": \"Alice Johnson\",\n \"position\": \"Senior Software Engineer\",\n \"department\": \"Engineering\",\n \"status\": \"active\",\n \"seniority\": \"senior\",\n \"manager\": \"Bob Smith\",\n \"hireDate\": \"2018-04-12\",\n \"salary\": 120000\n },\n {\n \"employeeId\": \"E002\",\n \"name\": \"Carlos Martinez\",\n \"position\": \"Junior Analyst\",\n \"department\": \"Finance\",\n \"status\": \"active\",\n \"seniority\": \"junior\",\n \"manager\": \"Dana Lee\",\n \"hireDate\": \"2021-09-01\",\n \"salary\": 65000\n },\n {\n \"employeeId\": \"E003\",\n \"name\": \"Emily Zhang\",\n \"position\": \"HR Manager\",\n \"department\": \"Human Resources\",\n \"status\": \"inactive\",\n \"seniority\": \"mid\",\n \"manager\": \"Frank Wu\",\n \"hireDate\": \"2015-02-20\",\n \"salary\": 95000\n },\n {\n \"employeeId\": \"E004\",\n \"name\": \"Michael Patel\",\n \"position\": \"Senior DevOps Engineer\",\n \"department\": \"Engineering\",\n \"status\": \"active\",\n \"seniority\": \"senior\",\n \"manager\": \"Bob Smith\",\n \"hireDate\": \"2017-07-15\",\n \"salary\": 115000\n },\n {\n \"employeeId\": \"E005\",\n \"name\": \"Sofia Rossi\",\n \"position\": \"Mid-level Marketing Specialist\",\n \"department\": \"Marketing\",\n \"status\": \"active\",\n \"seniority\": \"mid\",\n \"manager\": \"Grace Kim\",\n \"hireDate\": \"2019-11-03\",\n \"salary\": 72000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show active employees in Engineering.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving active Engineering employees...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show active employees in Engineering.\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"active\"\n }\n },\n {\n \"term\": {\n \"department\": \"Engineering\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"hireDate\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show active employees in the Engineering department with senior level.\n\nRephrased Query: List active employees where department is Engineering and seniority is senior.\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"active\"\n }\n },\n {\n \"term\": {\n \"department\": \"Engineering\"\n }\n },\n {\n \"term\": {\n \"seniority\": \"senior\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"hireDate\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaign Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"MKT-001\",\n \"title\": \"Spring Sale Campaign Launch\",\n \"description\": \"Prepare assets and schedule for the spring sale across all channels.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"campaign\",\n \"assignee\": \"marketing\",\n \"createdAt\": \"2025-10-01T08:15:00Z\",\n \"price\": 15000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Launch assets for spring sale.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"MKT-002\",\n \"title\": \"Email Newsletter Q4\",\n \"description\": \"Design and send the Q4 newsletter to the subscriber list.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"content\",\n \"createdAt\": \"2025-09-20T11:30:00Z\",\n \"price\": 5000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Draft Q4 newsletter content.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"MKT-003\",\n \"title\": \"Social Media Ads Review\",\n \"description\": \"Review and approve social media ad creatives for the upcoming product launch.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"ads\",\n \"assignee\": \"creative\",\n \"createdAt\": \"2025-08-15T14:45:00Z\",\n \"price\": 3000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Approve ad creatives.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the first 10 tickets in the Marketing Campaign Tickets index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List open high-priority tickets assigned to marketing team\n\nRephrased Query: Retrieve open tickets with high priority that are assigned to the marketing team\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"marketing\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaign Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: IT Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCKT-001\",\n \"title\": \"Cannot connect to VPN\",\n \"description\": \"User reports inability to establish VPN connection after password change.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-002\",\n \"title\": \"Email sync failure on mobile\",\n \"description\": \"Outlook mobile app not syncing new emails for several users.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"email team\",\n \"createdAt\": \"2025-10-18T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-003\",\n \"title\": \"Printer jam in Finance department\",\n \"description\": \"Laser printer repeatedly jams when printing large PDFs.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"hardware support\",\n \"createdAt\": \"2025-09-30T09:05:45Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-004\",\n \"title\": \"Slow network performance on floor 3\",\n \"description\": \"Users experience latency and packet loss on the third floor network segment.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2025-10-22T11:20:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-005\",\n \"title\": \"Software license renewal reminder\",\n \"description\": \"Reminder to renew Adobe Creative Cloud licenses for design team.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-08-15T16:30:20Z\",\n \"price\": 1200\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"I need a quick list of open tickets.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here's a list of all tickets with status 'open'.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 recent tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show me 42 high-priority network tickets assigned to tech support\n\nRephrased Query: List 42 tickets where status is open, priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 42,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "IT Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "semantic_question", "size": 42, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Sales Orders\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"productId\": \"PRD-200\",\n \"title\": \"Order not processed\",\n \"description\": \"Customer reports that order #2001 is not processed.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"order\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 1250,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Order not processed description...\",\n \"embedding\": []\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"productId\": \"PRD-305\",\n \"title\": \"Invoice discrepancy\",\n \"description\": \"Invoice amount differs from quoted price.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2025-10-18T14:42:10Z\",\n \"price\": 980.5,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Invoice discrepancy details...\",\n \"embedding\": []\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"productId\": \"PRD-410\",\n \"title\": \"Shipment delayed\",\n \"description\": \"Customer reports shipment delay for order #3003.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"logistics\",\n \"assignee\": \"mike.lee\",\n \"createdAt\": \"2025-10-15T09:05:45Z\",\n \"price\": 450.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Shipment delay explanation...\",\n \"embedding\": []\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the latest tickets from the Sales Orders index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Sales Orders", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"Patient Admission Form\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Emergency\",\n \"createdAt\": \"2023-11-05T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"finalized\",\n \"category\": \"admission\",\n \"tags\": [\n \"triage\",\n \"initial assessment\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Radiology Report - Chest X-Ray\",\n \"author\": \"Dr. Bob Lee\",\n \"department\": \"Radiology\",\n \"createdAt\": \"2024-02-12T14:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"reviewed\",\n \"category\": \"diagnostic\",\n \"tags\": [\n \"x-ray\",\n \"chest\",\n \"findings\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Discharge Summary - John Doe\",\n \"author\": \"Nurse Carol Nguyen\",\n \"department\": \"Cardiology\",\n \"createdAt\": \"2024-07-20T10:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"finalized\",\n \"category\": \"discharge\",\n \"tags\": [\n \"cardiology\",\n \"follow-up\"\n ],\n \"confidentialityLevel\": \"high\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list all the medical documents available?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I can retrieve the documents for you. Do you have any specific filters or a count in mind?\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all records\",\n \"dsl_type\": \"match_all\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all documents without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Corporate News Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Update 2024\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"internal\",\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"All employees must use multi‑factor authentication for remote access.\",\n \"embedding\": [\n 0\n ]\n }\n ]\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Department Quarterly Report Q1 2024\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\",\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Revenue increased by 8% compared to Q4 2023.\",\n \"embedding\": [\n 0\n ]\n }\n ]\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-12-01T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\",\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Employees may work from home up to three days per week.\",\n \"embedding\": [\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent approved documents\",\n \"dsl_type\": \"simple_match_all\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show me $42 approved PDFs from Finance department after 2024\n\nRephrased Query: Retrieve 42 approved PDF documents belonging to the Finance department with a creation date later than 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 42,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": \"finance policy\"\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Corporate News Articles", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 42, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Corporate Blog Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Department Budget Guidelines 2024\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-01-10T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"budget\",\n \"finance\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Best Practices\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-12-05T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"best practices\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Data Privacy Regulations Summary\",\n \"author\": \"david.kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-03-20T11:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"regulation\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"regulation\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-04-01T10:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest approved policies from IT Security?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policy documents belonging to the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all draft documents in Finance\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"draft\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policies\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Corporate Blog Posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaign Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"MKT-001\",\n \"title\": \"Spring Sale Email Campaign\",\n \"description\": \"Create and schedule email blasts for the spring sale.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"email\",\n \"assignee\": \"Alice\",\n \"createdAt\": \"2025-10-01T09:15:00Z\",\n \"price\": 1500\n },\n {\n \"ticketId\": \"MKT-002\",\n \"title\": \"Social Media Ads for New Product\",\n \"description\": \"Design and launch Facebook and Instagram ads.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"social_media\",\n \"assignee\": \"Bob\",\n \"createdAt\": \"2025-09-20T14:30:00Z\",\n \"price\": 2500\n },\n {\n \"ticketId\": \"MKT-003\",\n \"title\": \"Landing Page Optimization\",\n \"description\": \"A/B test landing page variants to improve conversion.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"web\",\n \"assignee\": \"Charlie\",\n \"createdAt\": \"2025-08-15T11:45:00Z\",\n \"price\": 800\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List all tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the tickets currently in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show open high-priority marketing tickets assigned to Alice\n\nRephrased Query: List tickets where status is open, priority is high, and assignee is Alice\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"Alice\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaign Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Sales Orders\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCKT-001\",\n \"productId\": \"PRD-1001\",\n \"title\": \"Order for Widget A\",\n \"description\": \"Customer requested 50 units of Widget A with expedited shipping.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"hardware\",\n \"assignee\": \"alice.smith\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 1250,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer requested 50 units of Widget A with expedited shipping.\",\n \"embedding\": null\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-002\",\n \"productId\": \"PRD-2002\",\n \"title\": \"Order for Service Subscription\",\n \"description\": \"Annual subscription renewal for premium support services.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"services\",\n \"assignee\": \"bob.jones\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 3000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Annual subscription renewal for premium support services.\",\n \"embedding\": null\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-003\",\n \"productId\": \"PRD-3003\",\n \"title\": \"Order for Software License\",\n \"description\": \"Purchase of 20 licenses for Enterprise Suite.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"carol.lee\",\n \"createdAt\": \"2025-11-01T10:05:45Z\",\n \"price\": 8000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Purchase of 20 licenses for Enterprise Suite.\",\n \"embedding\": null\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Sales Orders", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SC-001\",\n \"title\": \"Annual Supply Agreement with Alpha Corp\",\n \"description\": \"Contract for supplying electronic components for fiscal year 2025.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"electronics\",\n \"assignee\": \"jdoe\",\n \"createdAt\": \"2024-09-12T08:30:00Z\",\n \"price\": 125000\n },\n {\n \"ticketId\": \"SC-002\",\n \"title\": \"Renewal of Raw Material Contract - Beta Ltd\",\n \"description\": \"Renewal of steel raw material supply for Q1‑Q4 2025.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"raw_materials\",\n \"assignee\": \"asmith\",\n \"createdAt\": \"2024-06-05T14:15:00Z\",\n \"price\": 98000\n },\n {\n \"ticketId\": \"SC-003\",\n \"title\": \"One‑Time Procurement of Packaging Materials\",\n \"description\": \"Purchase of eco‑friendly packaging for upcoming product launch.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"packaging\",\n \"assignee\": \"mjones\",\n \"createdAt\": \"2024-10-01T10:45:00Z\",\n \"price\": 15000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List high‑priority contracts assigned to jdoe\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, fetching contracts with priority high and assignee jdoe...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Sales Orders\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCKT-1001\",\n \"productId\": \"PRD-2001\",\n \"title\": \"Order delay for product PRD-2001\",\n \"description\": \"Customer reported a delay in shipping for order #1001.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"logistics\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-11-01T08:15:30Z\",\n \"price\": 1250.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer reported a delay in shipping for order #1001.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-1002\",\n \"productId\": \"PRD-2003\",\n \"title\": \"Invoice discrepancy\",\n \"description\": \"The invoice amount does not match the quoted price.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2024-10-28T14:42:10Z\",\n \"price\": 980,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"The invoice amount does not match the quoted price.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCKT-1003\",\n \"productId\": \"PRD-2010\",\n \"title\": \"Request for product upgrade\",\n \"description\": \"Customer wants to upgrade from version 1.0 to 2.0.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"support\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2024-09-15T09:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer wants to upgrade from version 1.0 to 2.0.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Sales Orders", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: product_catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P1001\",\n \"title\": \"Enterprise Router X200\",\n \"description\": \"High‑performance router for large scale networks.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 1299.99,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P1002\",\n \"title\": \"Secure Firewall Z5\",\n \"description\": \"Advanced firewall with AI‑driven threat detection.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"security\",\n \"assignee\": \"security team\",\n \"createdAt\": \"2024-08-05T14:42:10Z\",\n \"price\": 799.5,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P1003\",\n \"title\": \"Cloud Storage Pro\",\n \"description\": \"Scalable cloud storage solution with redundancy.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"storage\",\n \"assignee\": \"cloud ops\",\n \"createdAt\": \"2024-07-20T11:03:45Z\",\n \"price\": 499,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest tickets.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent tickets.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: List 30 high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 30 tickets where status is open, priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 30,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "product_catalog", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 30, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Research Papers\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Security Policies for Remote Work\",\n \"author\": \"Alice Johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Financial Risk Assessment Q1 2024\",\n \"author\": \"Bob Martinez\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T14:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"risk\",\n \"finance\",\n \"Q1\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Data Privacy Guidelines\",\n \"author\": \"Carol Lee\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-12-01T11:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"privacy\",\n \"data\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest approved policies from IT Security.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent documents\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List 24 approved policies from IT Security\n\nRephrased Query: Retrieve 24 documents where status is approved and department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 24,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Research Papers", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 24, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Support Ticket Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experience high latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal of enterprise software licenses for Q1.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"account\",\n \"assignee\": \"account_manager\",\n \"createdAt\": \"2024-03-05T14:22:10Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Printer not printing\",\n \"description\": \"Office printer stops printing after the first page.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"it_support\",\n \"createdAt\": \"2024-07-21T09:45:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Billing discrepancy\",\n \"description\": \"Customer reports an overcharge on the latest invoice.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"billing\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2024-11-02T11:30:45Z\",\n \"price\": 250.75\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"Email delivery failure\",\n \"description\": \"Outgoing emails are bouncing with error 550.\",\n \"status\": \"open\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-09-18T16:05:20Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving all tickets with status open.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: Retrieve all tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Support Ticket Catalog", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Research Papers\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"RP-001\",\n \"title\": \"Advances in Quantum Computing\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Physics\",\n \"createdAt\": \"2023-05-12T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"research\",\n \"tags\": [\n \"quantum\",\n \"computing\",\n \"technology\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"RP-002\",\n \"title\": \"Machine Learning for Healthcare\",\n \"author\": \"Prof. Bob Lee\",\n \"department\": \"Computer Science\",\n \"createdAt\": \"2024-01-20T14:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"research\",\n \"tags\": [\n \"machine learning\",\n \"healthcare\",\n \"AI\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"RP-003\",\n \"title\": \"Renewable Energy Policy Overview\",\n \"author\": \"Dr. Carol Nguyen\",\n \"department\": \"Environmental Studies\",\n \"createdAt\": \"2022-11-03T10:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"renewable\",\n \"energy\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest research papers on AI?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I can retrieve the most recent AI papers for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all approved research papers\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show documents\n\nRephrased Query: Retrieve a list of research papers without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Research Papers", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Payroll discrepancy for employee 123\",\n \"description\": \"Employee reports that the salary for March is lower than expected.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"compensation\",\n \"assignee\": \"HR Manager\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Request for new hire onboarding documents\",\n \"description\": \"Need to prepare onboarding checklist for new employee in Marketing.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"onboarding\",\n \"assignee\": \"Recruiter\",\n \"createdAt\": \"2025-10-18T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Update employee address information\",\n \"description\": \"Employee moved to a new residence and needs address updated in HR system.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"administrative\",\n \"assignee\": \"HR Assistant\",\n \"createdAt\": \"2025-09-30T11:45:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List high priority tickets assigned to the recruiter\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, fetching high priority tickets where the assignee is Recruiter.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high priority tickets assigned to the recruiter\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"Recruiter\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets assigned to HR manager\n\nRephrased Query: List open tickets where assignee is HR Manager\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"HR Manager\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"post-001\",\n \"title\": \"Exciting Product Launch!\",\n \"author\": \"alice_j\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"fileType\": \"post\",\n \"status\": \"published\",\n \"category\": \"announcement\",\n \"tags\": [\n \"product\",\n \"launch\",\n \"exciting\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"post-002\",\n \"title\": \"Weekly Team Stand‑up Summary\",\n \"author\": \"bob_k\",\n \"department\": \"Engineering\",\n \"createdAt\": \"2024-09-10T14:02:00Z\",\n \"fileType\": \"post\",\n \"status\": \"published\",\n \"category\": \"meeting\",\n \"tags\": [\n \"standup\",\n \"weekly\",\n \"summary\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-003\",\n \"title\": \"Remote Work Tips for 2025\",\n \"author\": \"carol_m\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-09-08T09:45:12Z\",\n \"fileType\": \"post\",\n \"status\": \"published\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"tips\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"post-004\",\n \"title\": \"Security Awareness Reminder\",\n \"author\": \"dave_s\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-09-05T11:20:45Z\",\n \"fileType\": \"post\",\n \"status\": \"published\",\n \"category\": \"reminder\",\n \"tags\": [\n \"security\",\n \"awareness\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-005\",\n \"title\": \"Celebrating 5 Years of Innovation\",\n \"author\": \"eve_l\",\n \"department\": \"Corporate\",\n \"createdAt\": \"2024-09-01T16:30:00Z\",\n \"fileType\": \"post\",\n \"status\": \"published\",\n \"category\": \"celebration\",\n \"tags\": [\n \"anniversary\",\n \"innovation\",\n \"milestone\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest posts from the Marketing department.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent Marketing posts...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent internal documents\",\n \"dsl_type\": \"semantic_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match\": {\n \"confidentialityLevel\": \"internal\"\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 22 recent social media posts\n\nRephrased Query: Retrieve 22 latest social media posts without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 22,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "listing", "size": 22, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue in region EU-West\",\n \"description\": \"Customers report intermittent latency spikes affecting video streaming.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Billing discrepancy for enterprise plan\",\n \"description\": \"Invoice shows extra charges for the month of September.\",\n \"status\": \"pending\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"finance team\",\n \"createdAt\": \"2024-09-28T14:42:10Z\",\n \"price\": 1250.75\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Password reset failure for user JohnDoe\",\n \"description\": \"Password reset email never arrives.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"account\",\n \"assignee\": \"customer service\",\n \"createdAt\": \"2024-08-05T11:03:45Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the latest tickets in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List high-priority network tickets assigned to tech support\n\nRephrased Query: Retrieve tickets where priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: IT Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCKT-1001\",\n \"productId\": \"PRD-01\",\n \"title\": \"Unable to connect to VPN\",\n \"description\": \"User reports that the VPN client fails to establish a connection after the recent update.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-28T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-1002\",\n \"productId\": \"PRD-03\",\n \"title\": \"Printer jam on 3rd floor\",\n \"description\": \"The laser printer in room 312 is constantly jamming when printing large documents.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"hardware_team\",\n \"createdAt\": \"2025-10-27T14:42:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-1003\",\n \"productId\": \"PRD-02\",\n \"title\": \"Email delivery delay\",\n \"description\": \"Outgoing emails are delayed by up to 30 minutes during peak hours.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"email\",\n \"assignee\": \"email_ops\",\n \"createdAt\": \"2025-10-20T08:05:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List all tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "IT Support Tickets", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Patient Admission Form\",\n \"author\": \"Dr. Smith\",\n \"department\": \"Cardiology\",\n \"createdAt\": \"2023-05-12T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"admission\",\n \"tags\": [\n \"patient\",\n \"admission\",\n \"cardiology\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Radiology Imaging Report\",\n \"author\": \"Dr. Lee\",\n \"department\": \"Radiology\",\n \"createdAt\": \"2024-01-20T14:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"review\",\n \"category\": \"imaging\",\n \"tags\": [\n \"xray\",\n \"mri\",\n \"report\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Hospital Security Policy\",\n \"author\": \"Security Office\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2022-11-01T09:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"access\"\n ],\n \"confidentialityLevel\": \"high\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the approved policies from IT Security...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"show tickets\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: list approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "refinement", "pattern_type": "narrow_scope", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Financial Transactions\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TXN-1001\",\n \"title\": \"Failed wire transfer to vendor\",\n \"description\": \"The wire transfer to Vendor XYZ failed due to insufficient funds.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"payment\",\n \"assignee\": \"finance_team\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 12500\n },\n {\n \"ticketId\": \"TXN-1002\",\n \"title\": \"Refund request for order #4521\",\n \"description\": \"Customer requested a refund for a returned product.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"refund\",\n \"assignee\": \"support_agent_3\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 250.75\n },\n {\n \"ticketId\": \"TXN-1003\",\n \"title\": \"Suspicious transaction flagged\",\n \"description\": \"Transaction flagged by fraud detection system for unusual amount.\",\n \"status\": \"open\",\n \"priority\": \"critical\",\n \"category\": \"fraud\",\n \"assignee\": \"risk_analyst\",\n \"createdAt\": \"2025-11-01T08:45:00Z\",\n \"price\": 98000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving all open tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high priority payment tickets assigned to finance_team\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"payment\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"finance_team\"\n }\n },\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List open tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Financial Transactions", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Reviews\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"rev-001\",\n \"title\": \"Wireless Earbuds Review\",\n \"author\": \"alice.smith\",\n \"department\": \"Consumer Electronics\",\n \"createdAt\": \"2024-03-12T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"audio\",\n \"tags\": [\n \"wireless\",\n \"battery life\",\n \"sound quality\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"rev-002\",\n \"title\": \"Smartphone X Camera Test\",\n \"author\": \"bob.jones\",\n \"department\": \"Mobile Devices\",\n \"createdAt\": \"2024-05-08T14:30:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"photography\",\n \"tags\": [\n \"low light\",\n \"stabilization\",\n \"resolution\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"rev-003\",\n \"title\": \"Laptop Pro Performance Benchmark\",\n \"author\": \"carla.lee\",\n \"department\": \"Computing\",\n \"createdAt\": \"2024-01-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"performance\",\n \"tags\": [\n \"CPU\",\n \"GPU\",\n \"thermal\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the latest tickets matching your request.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List recent tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: News Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Update 2024\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Quarterly Report Q2 2024\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-07-01T12:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"Q2\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-20T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Cybersecurity Incident Response Plan\",\n \"author\": \"david.khan\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-10T14:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"cybersecurity\",\n \"incident\",\n \"response\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Annual Sustainability Report 2023\",\n \"author\": \"emma.wilson\",\n \"department\": \"Corporate Affairs\",\n \"createdAt\": \"2024-02-05T10:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"sustainability\",\n \"annual\",\n \"2023\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policies\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policies in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policies\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc1\",\n \"title\": \"Quarterly Financial Report Q1\",\n \"author\": \"Alice\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-15T10:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc2\",\n \"title\": \"IT Security Policy\",\n \"author\": \"Bob\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-12-01T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc3\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Carol\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-05-20T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the approved policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: Retrieve the first 10 PDF documents belonging to the Finance department with a creation date on or after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Sales Orders\n\nField Mappings:\n{\n \"properties\": {\n \"orderId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"orderId\": \"SO-1001\",\n \"productId\": \"PR-2001\",\n \"title\": \"Order for Widget A\",\n \"description\": \"Customer requested 50 units of Widget A with expedited shipping.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"hardware\",\n \"assignee\": \"alice.smith\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 1250,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Customer requested 50 units of Widget A with expedited shipping.\",\n \"embedding\": [\n 0,\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"orderId\": \"SO-1002\",\n \"productId\": \"PR-2002\",\n \"title\": \"Order for Service Subscription\",\n \"description\": \"Annual subscription for premium support services.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"services\",\n \"assignee\": \"bob.jones\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 3000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Annual subscription for premium support services.\",\n \"embedding\": [\n 0,\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"orderId\": \"SO-1003\",\n \"productId\": \"PR-2003\",\n \"title\": \"Order for Software License\",\n \"description\": \"License for 100 user seats of Enterprise Suite.\",\n \"status\": \"pending\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"carol.lee\",\n \"createdAt\": \"2025-11-01T09:05:45Z\",\n \"price\": 8500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"License for 100 user seats of Enterprise Suite.\",\n \"embedding\": [\n 0,\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest sales orders?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent orders...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show me 10 recent orders\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show me 19 sales orders\n\nRephrased Query: list 19 sales orders without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 19,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Sales Orders", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "categorical_listing", "size": 19, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"salary\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"HR-001\",\n \"title\": \"Onboarding paperwork missing\",\n \"description\": \"New hire Jane Smith has not submitted her tax forms.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"onboarding\",\n \"assignee\": \"John Doe\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"salary\": 0\n },\n {\n \"ticketId\": \"HR-002\",\n \"title\": \"Salary discrepancy for Q3\",\n \"description\": \"Employee Michael Brown reports a $500 shortfall in his paycheck.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"payroll\",\n \"assignee\": \"Emily Clark\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"salary\": 75000\n },\n {\n \"ticketId\": \"HR-003\",\n \"title\": \"Access request for HR portal\",\n \"description\": \"Laura Wilson needs read‑only access to the benefits portal.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"access\",\n \"assignee\": \"John Doe\",\n \"createdAt\": \"2025-08-05T11:45:00Z\",\n \"salary\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open HR tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open HR tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show open HR tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show high‑priority HR tickets assigned to John Doe\n\nRephrased Query: List HR tickets with priority high assigned to John Doe\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"John Doe\"\n }\n },\n {\n \"term\": {\n \"category\": \"HR\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "semantic_question", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experiencing high latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Network latency issue affecting VPN.\",\n \"embedding\": []\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal of Adobe Creative Cloud licenses for design team.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-03-15T14:30:00Z\",\n \"price\": 1200.5,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"License renewal details.\",\n \"embedding\": []\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Printer malfunction\",\n \"description\": \"Office printer jam and low toner.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"facilities\",\n \"createdAt\": \"2025-01-10T09:45:00Z\",\n \"price\": 150.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Printer issue description.\",\n \"embedding\": []\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the open tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the open tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: List 20 high-priority network tickets assigned to tech_support\n\nRephrased Query: Retrieve 20 tickets where status is open, priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 20,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 20, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Academic Articles - Policy Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy – Access Control\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"access\",\n \"control\",\n \"authentication\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Finance Department – Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-03-10\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"expense\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"HR Policy – Employee Confidentiality\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-20\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"policy\",\n \"tags\": [\n \"confidentiality\",\n \"employee\",\n \"data\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"IT Security Policy – Incident Response\",\n \"author\": \"david.kim\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-05\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"procedure\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Finance Department – Data Retention Schedule\",\n \"author\": \"emma.wilson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-01\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"schedule\",\n \"tags\": [\n \"retention\",\n \"data\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest IT security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved IT Security policies.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 approved policies from IT Security\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"multi_match\": {\n \"query\": \"policy\",\n \"fields\": [\n \"title^2\",\n \"tags\",\n \"category\"\n ]\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 48 approved policies from IT Security after 2024-01-01\n\nRephrased Query: Retrieve 48 approved IT Security policy documents created on or after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 48,\n \"from\": 96,\n \"query\": {\n \"hybrid\": {\n \"query\": {\n \"multi_match\": {\n \"query\": \"policy\",\n \"fields\": [\n \"title^3\",\n \"tags\",\n \"category\"\n ]\n }\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Academic Articles - Policy Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "pagination", "pattern_type": "next_page", "size": 48, "from": 96, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"MC-001\",\n \"title\": \"Launch Summer Promo\",\n \"description\": \"Prepare assets for the summer promotion campaign.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"campaign\",\n \"assignee\": \"Alice\",\n \"createdAt\": \"2025-09-15T08:30:00Z\",\n \"price\": 15000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Create banner designs and email templates.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"MC-002\",\n \"title\": \"Email List Segmentation\",\n \"description\": \"Segment the email list for targeted offers.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"analytics\",\n \"assignee\": \"Bob\",\n \"createdAt\": \"2025-09-10T11:45:00Z\",\n \"price\": 8000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Use demographic data to create segments.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"MC-003\",\n \"title\": \"Social Media Ads Review\",\n \"description\": \"Review and approve social media ad creatives.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"advertising\",\n \"assignee\": \"Charlie\",\n \"createdAt\": \"2025-08-28T14:20:00Z\",\n \"price\": 5000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Check compliance with brand guidelines.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List all tickets.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the tickets in the Marketing Campaigns index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets.\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show open high-priority marketing tickets assigned to Alice\n\nRephrased Query: List open tickets with high priority assigned to Alice\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"Alice\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: IT Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Cannot connect to VPN\",\n \"description\": \"User reports inability to establish VPN connection after password change.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Email sync issue on mobile\",\n \"description\": \"Outlook app on iOS not syncing recent emails.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"mobile_team\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license expired\",\n \"description\": \"Design software license expired, causing startup failures.\",\n \"status\": \"in_progress\",\n \"priority\": \"high\",\n \"category\": \"software\",\n \"assignee\": \"license_admin\",\n \"createdAt\": \"2025-11-01T10:05:45Z\",\n \"price\": 199.99\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List all tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the latest tickets in the system.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List all tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "IT Support Tickets", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Approved Policy\",\n \"author\": \"Jane Doe\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"approved\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"John Smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"quarterly\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Emily Clark\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01T08:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"text_expansion\": {\n \"field\": \"title\",\n \"model_id\": \"my-embedding-model\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text_expansion\": {\n \"field\": \"title\",\n \"model_id\": \"my-embedding-model\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Reviews\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"PR-001\",\n \"title\": \"Q1 2024 Product Review Summary\",\n \"author\": \"alice.smith\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-04-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"summary\",\n \"tags\": [\n \"Q1\",\n \"2024\",\n \"summary\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"PR-002\",\n \"title\": \"Customer Feedback Analysis - Finance Products\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-06-02T14:12:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"analysis\",\n \"tags\": [\n \"feedback\",\n \"finance\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"PR-003\",\n \"title\": \"Security Policy Overview\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-12-20T11:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"PR-004\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"david.kim\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-01-10T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"PR-005\",\n \"title\": \"Annual Sales Report 2023\",\n \"author\": \"emma.wilson\",\n \"department\": \"Sales\",\n \"createdAt\": \"2024-02-28T16:20:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"sales\",\n \"2023\",\n \"annual\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving approved IT Security policies...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: Show PDF documents in the Finance department created after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"employeeId\": {\n \"type\": \"keyword\"\n },\n \"employeeName\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"hireDate\": {\n \"type\": \"date\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"productId\": \"PRD-100\",\n \"title\": \"Network latency issue\",\n \"description\": \"User reports intermittent network latency affecting VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:00Z\",\n \"price\": 0,\n \"employeeId\": \"E123\",\n \"employeeName\": \"Alice Johnson\",\n \"department\": \"IT\",\n \"hireDate\": \"2020-04-15\"\n },\n {\n \"ticketId\": \"TCK-002\",\n \"productId\": \"PRD-200\",\n \"title\": \"Payroll discrepancy\",\n \"description\": \"Salary for March was underpaid by $200.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"finance\",\n \"assignee\": \"hr_payroll\",\n \"createdAt\": \"2025-03-28T14:30:00Z\",\n \"price\": 0,\n \"employeeId\": \"E456\",\n \"employeeName\": \"Bob Smith\",\n \"department\": \"Finance\",\n \"hireDate\": \"2018-09-01\"\n },\n {\n \"ticketId\": \"TCK-003\",\n \"productId\": \"PRD-300\",\n \"title\": \"Access request for HR portal\",\n \"description\": \"New hire needs access to HR self‑service portal.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"access\",\n \"assignee\": \"it_admin\",\n \"createdAt\": \"2025-01-10T09:45:00Z\",\n \"price\": 0,\n \"employeeId\": \"E789\",\n \"employeeName\": \"Carol Lee\",\n \"department\": \"HR\",\n \"hireDate\": \"2025-01-01\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the open tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: List high‑priority network tickets assigned to tech support\n\nRephrased Query: Retrieve open tickets where priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 20,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n },\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "specific_page", "size": 10, "from": 20, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P1001\",\n \"title\": \"Enterprise Router X200\",\n \"description\": \"High‑performance router for large networks.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 1299.99,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Enterprise Router X200 supports up to 10 Gbps throughput.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"productId\": \"P1002\",\n \"title\": \"Secure Firewall Pro\",\n \"description\": \"Advanced firewall with AI threat detection.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"security\",\n \"assignee\": \"security team\",\n \"createdAt\": \"2024-08-05T14:22:10Z\",\n \"price\": 799.5,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Firewall Pro integrates with existing security infrastructure.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"productId\": \"P1003\",\n \"title\": \"Wireless Access Point WAP‑A1\",\n \"description\": \"Dual‑band AP for office environments.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech support\",\n \"createdAt\": \"2024-10-01T09:45:00Z\",\n \"price\": 199,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"WAP‑A1 provides seamless roaming across multiple floors.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 41 high‑priority network tickets assigned to tech support\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will build a query that returns 41 tickets matching those filters.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show 41 high‑priority network tickets assigned to tech support\n\nRephrased Query: Retrieve 41 tickets where status is open, priority is high, category is network, and assignee is tech support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 41,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 41, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n },\n \"documentContentWords\": {\n \"type\": \"text\"\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"title\": \"Onboarding paperwork missing\",\n \"description\": \"New hire John Doe has not submitted required onboarding documents.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"administration\",\n \"assignee\": \"hr_specialist_1\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-002\",\n \"title\": \"Salary discrepancy for Q3\",\n \"description\": \"Employee reports that the salary credited for Q3 is lower than expected.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"payroll\",\n \"assignee\": \"finance_analyst_2\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-003\",\n \"title\": \"Access request to HR portal\",\n \"description\": \"Manager requests access for new team member to view employee records.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"access_control\",\n \"assignee\": \"it_support_3\",\n \"createdAt\": \"2025-08-05T11:45:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-004\",\n \"title\": \"Benefit enrollment issue\",\n \"description\": \"Employee cannot enroll in health benefits due to system error.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"benefits\",\n \"assignee\": \"hr_specialist_2\",\n \"createdAt\": \"2025-10-22T08:20:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-005\",\n \"title\": \"Incorrect vacation balance\",\n \"description\": \"Vacation days shown are less than accrued days for employee Jane Smith.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"time_off\",\n \"assignee\": \"hr_specialist_1\",\n \"createdAt\": \"2025-07-30T16:00:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving all open tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List open tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"IT Security Policy - Access Control\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"access\",\n \"control\",\n \"authentication\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Finance Department Quarterly Report Q1 2024\",\n \"author\": \"bob.johnson\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"quarterly\",\n \"revenue\",\n \"expenses\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-20T08:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"low\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"Patient Data Confidentiality Agreement\",\n \"author\": \"david.khan\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-05T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"agreement\",\n \"tags\": [\n \"patient\",\n \"confidentiality\",\n \"HIPAA\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-22T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"high\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show 20 approved policies from IT Security.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the 20 approved IT Security policies you requested.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent finance reports\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"category\": \"report\"\n }\n }\n ],\n \"filter\": [\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"now-1y\"\n }\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 37 approved policies from IT Security department after 2023-12-31\n\nRephrased Query: Retrieve 37 documents where status is approved, department is IT Security, fileType is pdf, and createdAt is later than 2023-12-31\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 37,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": {\n \"query\": \"approved policies\",\n \"fields\": [\n \"title\",\n \"tags\"\n ]\n },\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 37\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ],\n \"filter\": [\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2023-12-31T00:00:00Z\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 37, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Legal Documents\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Approved Policy\",\n \"author\": \"Alice Johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"access\",\n \"encryption\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Finance Quarterly Report Q1 2024\",\n \"author\": \"Bob Martinez\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T14:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"report\",\n \"tags\": [\n \"quarterly\",\n \"revenue\",\n \"expenses\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"Carol Lee\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-20T08:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"policy\",\n \"equipment\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-004\",\n \"title\": \"Legal Compliance Checklist 2024\",\n \"author\": \"David Kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-05T11:20:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"checklist\",\n \"tags\": [\n \"compliance\",\n \"regulation\",\n \"audit\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"DOC-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"Evelyn Smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-09-30T16:10:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"plan\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"procedure\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest approved policies from the IT Security department?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policies from IT Security.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-768\",\n \"model_text\": \"approved policies\"\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: Retrieve all documents where status is approved and department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"text_expansion\": {\n \"model_id\": \"text-embedding-768\",\n \"model_text\": \"approved policies\"\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Legal Documents", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Profiles\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Unable to access VPN\",\n \"description\": \"User reports that the corporate VPN connection fails with error code 720.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support_01\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"User cannot connect to VPN due to authentication failure.\",\n \"embedding\": [\n 0,\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Invoice discrepancy for March\",\n \"description\": \"The total amount billed for March exceeds the agreed contract price.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"account_manager_07\",\n \"createdAt\": \"2025-03-15T14:42:10Z\",\n \"price\": 1250.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Invoice shows $5,000 instead of $4,500.\",\n \"embedding\": [\n 0,\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Feature request: Dark mode\",\n \"description\": \"Customer requests a dark mode option for the web portal.\",\n \"status\": \"open\",\n \"priority\": \"low\",\n \"category\": \"feature\",\n \"assignee\": \"product_owner_03\",\n \"createdAt\": \"2025-11-01T09:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Add a toggle for dark mode in user settings.\",\n \"embedding\": [\n 0,\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent tickets sorted by creation date.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show me 21 tickets\n\nRephrased Query: Retrieve the latest 21 tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 21,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Customer Profiles", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "complex_query", "size": 21, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Corporate Policy Blog Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Password Policy\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"security\",\n \"tags\": [\n \"password\",\n \"authentication\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Finance Department Expense Policy\",\n \"author\": \"carla.wu\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-05-20T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"finance\",\n \"tags\": [\n \"expense\",\n \"reimbursement\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Data Retention Schedule\",\n \"author\": \"david.lee\",\n \"department\": \"Legal\",\n \"createdAt\": \"2023-09-10T08:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"compliance\",\n \"tags\": [\n \"data\",\n \"retention\",\n \"schedule\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-05T10:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"security\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"plan\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policy documents.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List PDFs from Finance department after 2024\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: List approved policy documents in the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Corporate Policy Blog Posts", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "pagination", "pattern_type": "specific_page", "size": 10, "from": 0, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: News Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Global Economic Outlook 2025\",\n \"author\": \"Jane Smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-11-01T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Economy\",\n \"tags\": [\n \"economy\",\n \"forecast\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Cybersecurity Best Practices\",\n \"author\": \"Alan Doe\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-06-15T14:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Security\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"remote work\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Climate Change Impact Report\",\n \"author\": \"Maria Garcia\",\n \"department\": \"Environment\",\n \"createdAt\": \"2024-02-10T10:05:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"Environment\",\n \"tags\": [\n \"climate\",\n \"report\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"restricted\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: list documents\n\nRephrased Query: retrieve a list of documents without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Academic Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Advances in Quantum Computing\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Physics\",\n \"createdAt\": \"2023-11-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"research\",\n \"tags\": [\n \"quantum\",\n \"computing\",\n \"technology\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Financial Risk Assessment 2024\",\n \"author\": \"John Doe\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-02-20T14:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"risk\",\n \"assessment\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Machine Learning in Healthcare\",\n \"author\": \"Dr. Emily Zhang\",\n \"department\": \"Medicine\",\n \"createdAt\": \"2022-07-08T11:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"study\",\n \"tags\": [\n \"machine learning\",\n \"healthcare\",\n \"AI\"\n ],\n \"confidentialityLevel\": \"restricted\"\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show PDFs from Finance department after 2024\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List PDFs from Finance department after 2024\n\nRephrased Query: List documents where fileType is PDF, department is Finance, and createdAt is after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Academic Articles", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"employeeId\": {\n \"type\": \"keyword\"\n },\n \"name\": {\n \"type\": \"text\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"hireDate\": {\n \"type\": \"date\"\n },\n \"salary\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"employeeId\": \"E001\",\n \"name\": \"Alice Johnson\",\n \"title\": \"Senior Software Engineer\",\n \"department\": \"Engineering\",\n \"status\": \"active\",\n \"hireDate\": \"2018-04-12\",\n \"salary\": 115000,\n \"documentContentWordsChunked\": []\n },\n {\n \"employeeId\": \"E002\",\n \"name\": \"Bob Martinez\",\n \"title\": \"HR Business Partner\",\n \"department\": \"Human Resources\",\n \"status\": \"active\",\n \"hireDate\": \"2016-09-03\",\n \"salary\": 90000,\n \"documentContentWordsChunked\": []\n },\n {\n \"employeeId\": \"E003\",\n \"name\": \"Carol Singh\",\n \"title\": \"Finance Analyst\",\n \"department\": \"Finance\",\n \"status\": \"on_leave\",\n \"hireDate\": \"2020-01-15\",\n \"salary\": 75000,\n \"documentContentWordsChunked\": []\n },\n {\n \"employeeId\": \"E004\",\n \"name\": \"David Lee\",\n \"title\": \"Marketing Coordinator\",\n \"department\": \"Marketing\",\n \"status\": \"active\",\n \"hireDate\": \"2019-07-22\",\n \"salary\": 62000,\n \"documentContentWordsChunked\": []\n },\n {\n \"employeeId\": \"E005\",\n \"name\": \"Eva Gomez\",\n \"title\": \"Product Manager\",\n \"department\": \"Product\",\n \"status\": \"active\",\n \"hireDate\": \"2017-11-30\",\n \"salary\": 105000,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show employee records\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I can list the employee records for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all employees\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"hireDate\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show employee records\n\nRephrased Query: List employee records without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"hireDate\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "semantic_question", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: IT Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"productId\": \"PRD-01\",\n \"title\": \"Cannot connect to VPN\",\n \"description\": \"User reports inability to establish VPN connection after password change.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support_1\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"User cannot connect to VPN after password change.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"productId\": \"PRD-02\",\n \"title\": \"Email sync failure on mobile\",\n \"description\": \"Outlook mobile app fails to sync new emails on iOS device.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"tech_support_2\",\n \"createdAt\": \"2025-10-18T14:42:10Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Outlook mobile app not syncing emails on iOS.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"productId\": \"PRD-03\",\n \"title\": \"Printer driver installation error\",\n \"description\": \"Installation of HP LaserJet driver returns error code 0x80004005.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"hardware\",\n \"assignee\": \"tech_support_3\",\n \"createdAt\": \"2025-09-30T09:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"HP LaserJet driver installation fails with error 0x80004005.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"productId\": \"PRD-04\",\n \"title\": \"Slow performance on ERP system\",\n \"description\": \"Users experience latency when loading dashboards in the ERP application.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"application\",\n \"assignee\": \"tech_support_4\",\n \"createdAt\": \"2025-10-22T11:20:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"ERP dashboards loading slowly for multiple users.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me 24 tickets from the IT support system.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the latest 24 tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 10 tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show me 24 tickets\n\nRephrased Query: list 24 tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 24,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "IT Support Tickets", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "keyword_search", "size": 24, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: HR Employee Records\n\nField Mappings:\n{\n \"properties\": {\n \"employeeId\": {\n \"type\": \"keyword\"\n },\n \"name\": {\n \"type\": \"text\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"hireDate\": {\n \"type\": \"date\"\n },\n \"salary\": {\n \"type\": \"double\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"employeeId\": \"E001\",\n \"name\": \"Alice Johnson\",\n \"title\": \"Senior Software Engineer\",\n \"department\": \"Engineering\",\n \"status\": \"Active\",\n \"hireDate\": \"2018-04-12\",\n \"salary\": 115000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Alice has led multiple backend projects.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"employeeId\": \"E002\",\n \"name\": \"Bob Martinez\",\n \"title\": \"HR Manager\",\n \"department\": \"Human Resources\",\n \"status\": \"Active\",\n \"hireDate\": \"2015-09-01\",\n \"salary\": 95000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Bob oversees recruitment and employee relations.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"employeeId\": \"E003\",\n \"name\": \"Carol Singh\",\n \"title\": \"Finance Analyst\",\n \"department\": \"Finance\",\n \"status\": \"On Leave\",\n \"hireDate\": \"2020-01-15\",\n \"salary\": 72000,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Carol specializes in budgeting and forecasting.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list all employee records?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the employee records for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all employees\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"hireDate\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show employee records\n\nRephrased Query: List employee records without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"hireDate\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "HR Employee Records", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"post-001\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"security\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-002\",\n \"title\": \"Data Encryption Standards\",\n \"author\": \"bob.jones\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-22T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"encryption\",\n \"data\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"post-003\",\n \"title\": \"Social Media Usage Policy\",\n \"author\": \"carol.lee\",\n \"department\": \"HR\",\n \"createdAt\": \"2023-11-08T08:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"draft\",\n \"category\": \"policy\",\n \"tags\": [\n \"social media\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show approved policies from IT Security\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest approved policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show approved policies from IT Security\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show approved policies from IT Security\n\nRephrased Query: list all approved policy documents belonging to the IT Security department\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "listing", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"MC-001\",\n \"title\": \"Spring Sale Campaign Launch\",\n \"description\": \"Prepare assets and schedule for the spring sale across all channels.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"campaign\",\n \"assignee\": \"marketing_team\",\n \"createdAt\": \"2025-09-15T08:30:00Z\",\n \"price\": 15000\n },\n {\n \"ticketId\": \"MC-002\",\n \"title\": \"Email Newsletter Q4\",\n \"description\": \"Draft and send the Q4 newsletter to the subscriber list.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"email\",\n \"assignee\": \"content_team\",\n \"createdAt\": \"2025-10-01T10:00:00Z\",\n \"price\": 5000\n },\n {\n \"ticketId\": \"MC-003\",\n \"title\": \"Social Media Ads Review\",\n \"description\": \"Review performance of social media ads and adjust budget.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"ads\",\n \"assignee\": \"ads_team\",\n \"createdAt\": \"2025-08-20T14:45:00Z\",\n \"price\": 3000\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n }\n }\n }\n]\n\nUser Query: Show open high-priority tickets assigned to marketing team\n\nRephrased Query: List open tickets with high priority assigned to marketing team\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"marketing_team\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: News Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"IT Security Policy Update 2024\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-03-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"HR\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Quarterly Financial Report Q2 2024\",\n \"author\": \"carol.lee\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-07-20T08:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"finance\",\n \"Q2\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Data Privacy Regulations Overview\",\n \"author\": \"david.kim\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-10T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"privacy\",\n \"regulation\",\n \"legal\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"IT Security Incident Response Plan\",\n \"author\": \"eve.martinez\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-05T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"security\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent finance reports\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"category\": \"report\"\n }\n }\n ]\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 49 approved policies from IT Security\n\nRephrased Query: Retrieve 49 documents where status is approved, category is policy, and department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 49,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"text_expansion\": {\n \"model_id\": \"my-text-expansion-model\",\n \"model_text\": \"approved policy\"\n }\n },\n {\n \"knn\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0.5\n ],\n \"k\": 49,\n \"num_candidates\": 100\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 49, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWords\": {\n \"type\": \"text\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P1001\",\n \"title\": \"Wireless Mouse\",\n \"description\": \"Ergonomic wireless mouse with adjustable DPI and long battery life.\",\n \"status\": \"available\",\n \"priority\": \"low\",\n \"category\": \"electronics\",\n \"assignee\": \"inventory_team\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"price\": 29.99,\n \"documentContentWords\": \"wireless mouse ergonomic adjustable DPI battery life\"\n },\n {\n \"productId\": \"P1002\",\n \"title\": \"Gaming Laptop\",\n \"description\": \"High-performance laptop with RTX graphics, 16GB RAM, and 1TB SSD.\",\n \"status\": \"out_of_stock\",\n \"priority\": \"high\",\n \"category\": \"computers\",\n \"assignee\": \"sales_team\",\n \"createdAt\": \"2024-08-25T14:42:10Z\",\n \"price\": 1499,\n \"documentContentWords\": \"gaming laptop RTX graphics 16GB RAM 1TB SSD\"\n },\n {\n \"productId\": \"P1003\",\n \"title\": \"Smartphone Pro\",\n \"description\": \"Flagship smartphone with triple camera system and 5G connectivity.\",\n \"status\": \"available\",\n \"priority\": \"medium\",\n \"category\": \"mobile\",\n \"assignee\": \"marketing_team\",\n \"createdAt\": \"2024-10-01T10:05:45Z\",\n \"price\": 999.99,\n \"documentContentWords\": \"smartphone triple camera 5G connectivity\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the latest documents for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list documents\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: Retrieve a list of recent documents without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Financial Transactions\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Failed payment processing for client A\",\n \"description\": \"The payment gateway returned error code 502 during settlement.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"payment\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 1250.75,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Incorrect invoice amount for account B\",\n \"description\": \"Invoice #INV-4523 shows $5,000 instead of $4,500.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"accounting_team\",\n \"createdAt\": \"2025-09-15T14:42:10Z\",\n \"price\": 4500,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Network latency affecting transaction logs\",\n \"description\": \"High latency observed in log replication between data centers.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-22T11:05:45Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Currency conversion discrepancy\",\n \"description\": \"EUR to USD conversion rate applied was outdated.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"conversion\",\n \"assignee\": \"finance_ops\",\n \"createdAt\": \"2025-10-01T09:30:00Z\",\n \"price\": 300,\n \"documentContentWordsChunked\": []\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"Unauthorized access attempt detected\",\n \"description\": \"Multiple failed login attempts from IP 192.168.12.34.\",\n \"status\": \"open\",\n \"priority\": \"critical\",\n \"category\": \"security\",\n \"assignee\": \"security_team\",\n \"createdAt\": \"2025-10-23T02:20:15Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving all tickets with status open.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List high‑priority network tickets assigned to tech support\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List all tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Financial Transactions", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Customer Support Tickets\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TCKT-001\",\n \"title\": \"IT Security Policy Update\",\n \"author\": \"alice.smith\",\n \"department\": \"IT\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-002\",\n \"title\": \"Finance Quarterly Report Q1\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-10T14:20:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"pending\",\n \"category\": \"report\",\n \"tags\": [\n \"quarterly\",\n \"finance\",\n \"Q1\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TCKT-003\",\n \"title\": \"HR Remote Work Guidelines\",\n \"author\": \"carol.lee\",\n \"department\": \"HR\",\n \"createdAt\": \"2023-12-01T08:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"TCKT-004\",\n \"title\": \"IT Incident Report - Server Outage\",\n \"author\": \"dave.khan\",\n \"department\": \"IT\",\n \"createdAt\": \"2024-09-05T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"closed\",\n \"category\": \"incident\",\n \"tags\": [\n \"outage\",\n \"server\",\n \"incident\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TCKT-005\",\n \"title\": \"Marketing Campaign Performance\",\n \"author\": \"eva.martinez\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-07-20T10:15:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"campaign\",\n \"performance\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest approved policies from the IT department?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved IT policies for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List pending finance reports\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"term\": {\n \"status\": \"pending\"\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show approved tickets from IT department\n\nRephrased Query: Retrieve all tickets with status approved and department IT\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": \"<embedding_placeholder>\",\n \"k\": 10\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Customer Support Tickets", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "refinement", "pattern_type": "narrow_scope", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Supplier Contracts\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"SC-1001\",\n \"productId\": \"PR-2001\",\n \"title\": \"Annual supply agreement for raw materials\",\n \"description\": \"Contract covering the delivery of steel rods for the fiscal year 2025.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"materials\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2024-11-01T08:30:00Z\",\n \"price\": 125000\n },\n {\n \"ticketId\": \"SC-1002\",\n \"productId\": \"PR-2002\",\n \"title\": \"Software licensing renewal\",\n \"description\": \"Renewal of enterprise software licenses for the accounting department.\",\n \"status\": \"closed\",\n \"priority\": \"medium\",\n \"category\": \"software\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2024-09-15T14:45:00Z\",\n \"price\": 45000\n },\n {\n \"ticketId\": \"SC-1003\",\n \"productId\": \"PR-2003\",\n \"title\": \"Logistics service contract\",\n \"description\": \"Agreement with third‑party logistics provider for quarterly shipments.\",\n \"status\": \"pending\",\n \"priority\": \"low\",\n \"category\": \"logistics\",\n \"assignee\": \"mike.lee\",\n \"createdAt\": \"2024-10-20T11:10:00Z\",\n \"price\": 30000\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving open tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: List open tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Supplier Contracts", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: News Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Global Economic Outlook 2025\",\n \"author\": \"Jane Smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-11-01T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Economy\",\n \"tags\": [\n \"forecast\",\n \"global\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Cybersecurity Best Practices for Remote Workers\",\n \"author\": \"Alan Chen\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-09-15T14:12:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"Security\",\n \"tags\": [\n \"remote work\",\n \"policy\",\n \"encryption\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Annual Climate Report 2023\",\n \"author\": \"Maria Garcia\",\n \"department\": \"Environment\",\n \"createdAt\": \"2024-01-20T10:05:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"Environment\",\n \"tags\": [\n \"climate\",\n \"report\",\n \"2023\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[]\n\nUser Query: Show tickets\n\nRephrased Query: List recent tickets\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "News Articles", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "simple_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc_001\",\n \"title\": \"Company Holiday Announcement\",\n \"author\": \"alice.smith\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-11-01T09:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"announcement\",\n \"tags\": [\n \"holiday\",\n \"schedule\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc_002\",\n \"title\": \"Quarterly Sales Results\",\n \"author\": \"bob.jones\",\n \"department\": \"Sales\",\n \"createdAt\": \"2024-10-15T14:30:00Z\",\n \"fileType\": \"xlsx\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"sales\",\n \"Q4\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc_003\",\n \"title\": \"Remote Work Policy Update\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-09-20T11:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"security\"\n ],\n \"confidentialityLevel\": \"restricted\"\n },\n {\n \"documentId\": \"doc_004\",\n \"title\": \"Marketing Campaign Overview\",\n \"author\": \"dave.kim\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-08-05T08:45:00Z\",\n \"fileType\": \"pptx\",\n \"status\": \"draft\",\n \"category\": \"presentation\",\n \"tags\": [\n \"campaign\",\n \"2025\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc_005\",\n \"title\": \"Security Incident Report\",\n \"author\": \"eve.martin\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-22T16:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"published\",\n \"category\": \"incident\",\n \"tags\": [\n \"security\",\n \"incident\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the most recent tickets for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Find documents about remote work policies\",\n \"dsl_type\": \"semantic_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 10\n }\n }\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: list recent tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"should\": [\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "listing_intent", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Academic Articles - Institutional Policies\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"POL-2024-001\",\n \"title\": \"IT Security Remote Work Policy\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"access\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"POL-2024-007\",\n \"title\": \"Data Encryption Standards\",\n \"author\": \"bob.johnson\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-03\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"encryption\",\n \"data\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"POL-2023-014\",\n \"title\": \"Incident Response Procedure\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-11-20\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"procedure\",\n \"tags\": [\n \"incident\",\n \"response\",\n \"workflow\"\n ],\n \"confidentialityLevel\": \"restricted\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest security policies?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 approved policies\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policy\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show 19 approved policy PDFs from IT Security department after 2023-01-01\n\nRephrased Query: Retrieve 19 approved policy documents of type PDF from the IT Security department created after 2023-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 19,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"text\": \"approved policy\",\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2023-01-01\"\n }\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Academic Articles - Institutional Policies", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 19, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Financial Transactions\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCKT-1001\",\n \"title\": \"Failed Wire Transfer\",\n \"description\": \"Customer reported a failed wire transfer of $5,000 to external account.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"finance\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-1002\",\n \"title\": \"Incorrect Transaction Fee\",\n \"description\": \"The system applied an extra $15 fee on a domestic transfer.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"billing\",\n \"assignee\": \"jane.smith\",\n \"createdAt\": \"2025-09-15T14:42:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-1003\",\n \"title\": \"Pending ACH Deposit\",\n \"description\": \"ACH deposit of $2,300 is still pending after 48 hours.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"finance\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-11-01T08:30:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-1004\",\n \"title\": \"Currency Conversion Error\",\n \"description\": \"Conversion from USD to EUR gave an incorrect rate.\",\n \"status\": \"in_progress\",\n \"priority\": \"low\",\n \"category\": \"exchange\",\n \"assignee\": \"alice.wang\",\n \"createdAt\": \"2025-10-05T11:20:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCKT-1005\",\n \"title\": \"Duplicate Transaction Alert\",\n \"description\": \"Customer received duplicate notification for a single transaction.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"finance\",\n \"assignee\": \"john.doe\",\n \"createdAt\": \"2025-11-10T16:05:00Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the latest tickets from the financial transactions index.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List open high‑priority finance tickets assigned to John\n\nRephrased Query: Show open tickets with priority high, category finance, and assignee John\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"finance\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"john.doe\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Financial Transactions", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Reviews\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"rev-001\",\n \"title\": \"Wireless Earbuds Review\",\n \"author\": \"alice\",\n \"department\": \"Electronics\",\n \"createdAt\": \"2024-02-15T10:23:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Audio\",\n \"tags\": [\n \"wireless\",\n \"earbuds\",\n \"sound quality\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"rev-002\",\n \"title\": \"Smartphone Battery Life Survey\",\n \"author\": \"bob\",\n \"department\": \"Mobile\",\n \"createdAt\": \"2023-11-08T14:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"pending\",\n \"category\": \"Battery\",\n \"tags\": [\n \"battery\",\n \"longevity\",\n \"performance\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"rev-003\",\n \"title\": \"Laptop Security Features Overview\",\n \"author\": \"carol\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-01T09:10:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Security\",\n \"tags\": [\n \"encryption\",\n \"TPM\",\n \"firmware\"\n ],\n \"confidentialityLevel\": \"restricted\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest approved reviews from the Electronics department?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve approved documents from Electronics. Do you need any specific file type?\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List approved reviews from Electronics after 2023-01-01\",\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"text_expansion\": {\n \"model_id\": \"my-semantic-model\",\n \"field\": \"documentContentWordsChunked.passage\",\n \"model_text\": \"approved reviews Electronics\"\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"Electronics\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2023-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n }\n]\n\nUser Query: Show approved reviews from Electronics department after 2023\n\nRephrased Query: Retrieve documents where status is approved, department is Electronics, and createdAt is on or after 2023-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"text_expansion\": {\n \"model_id\": \"my-semantic-model\",\n \"field\": \"documentContentWordsChunked.passage\",\n \"model_text\": \"approved reviews Electronics\"\n }\n }\n ],\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"Electronics\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2023-01-01\"\n }\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Product Reviews", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "refinement", "pattern_type": "add_filter", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Social Media Posts\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"post-001\",\n \"title\": \"Launch of New Feature\",\n \"author\": \"alice\",\n \"department\": \"Marketing\",\n \"createdAt\": \"2024-09-12T08:15:30Z\",\n \"fileType\": \"text\",\n \"status\": \"published\",\n \"category\": \"announcement\",\n \"tags\": [\n \"feature\",\n \"release\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"post-002\",\n \"title\": \"Team Building Event Recap\",\n \"author\": \"bob\",\n \"department\": \"HR\",\n \"createdAt\": \"2024-08-05T14:22:10Z\",\n \"fileType\": \"text\",\n \"status\": \"published\",\n \"category\": \"culture\",\n \"tags\": [\n \"team\",\n \"event\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"post-003\",\n \"title\": \"Quarterly Security Update\",\n \"author\": \"carol\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-07-20T10:00:00Z\",\n \"fileType\": \"text\",\n \"status\": \"draft\",\n \"category\": \"security\",\n \"tags\": [\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent social media posts\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show 39 recent social media posts\n\nRephrased Query: Retrieve 39 recent social media posts\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 39,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Social Media Posts", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "categorical_listing", "size": 39, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Support\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue on router\",\n \"description\": \"Customer reports intermittent latency spikes affecting VoIP calls.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-12T08:45:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Network latency issue on router causing VoIP disruptions.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Defective power supply unit\",\n \"description\": \"The PSU fails to start after the latest firmware update.\",\n \"status\": \"resolved\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"hardware_team\",\n \"createdAt\": \"2024-09-28T14:20:00Z\",\n \"price\": 199.99,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Defective power supply unit after firmware update.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Billing discrepancy for premium plan\",\n \"description\": \"Customer was overcharged by $15 for the month of March.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"account\",\n \"assignee\": \"billing_team\",\n \"createdAt\": \"2024-08-15T10:05:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Billing discrepancy for premium plan in March.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List all tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the tickets in the system...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open tickets\n\nRephrased Query: Retrieve tickets where status is open\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Support", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Technical Manuals\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"TM-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"TM-002\",\n \"title\": \"Finance Department Expense Guidelines\",\n \"author\": \"bob.jones\",\n \"department\": \"Finance\",\n \"createdAt\": \"2023-11-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"expenses\",\n \"reimbursement\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"TM-003\",\n \"title\": \"Remote Work Security Checklist\",\n \"author\": \"carol.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-05-20T08:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"checklist\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"checklist\"\n ],\n \"confidentialityLevel\": \"public\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest security policies.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 draft documents from Finance.\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"draft\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List 34 approved PDF policies from IT Security department after 2024.\n\nRephrased Query: Retrieve 34 approved PDF policy documents belonging to the IT Security department with a creation date later than 2024-01-01.\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 34,\n \"from\": 34,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Technical Manuals", "data_type": "unstructured", "query_type": "listing_with_filters", "pattern": "pagination", "pattern_type": "previous_page", "size": 34, "from": 34, "is_pagination": true }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Inventory Items\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue\",\n \"description\": \"Users experiencing high latency on VPN connections.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2025-10-20T08:15:30Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Network latency issue affecting VPN users.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Printer malfunction\",\n \"description\": \"Office printer prints blank pages intermittently.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"hardware\",\n \"assignee\": \"it_ops\",\n \"createdAt\": \"2025-10-18T14:42:10Z\",\n \"price\": 150.75,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Printer prints blank pages intermittently.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"Software license renewal\",\n \"description\": \"Renewal of Adobe Creative Cloud licenses for design team.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"software\",\n \"assignee\": \"procurement\",\n \"createdAt\": \"2025-09-30T09:05:00Z\",\n \"price\": 1200,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Renewal of Adobe Creative Cloud licenses.\",\n \"embedding\": [\n 0,\n 0,\n \"...\"\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the tickets for me?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the latest tickets.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: List tickets without any specific filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Inventory Items", "data_type": "structured", "query_type": "listing", "pattern": "initial", "pattern_type": "semantic_question", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"Patient Admission Form\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Emergency\",\n \"createdAt\": \"2023-11-02T08:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"admission\",\n \"tags\": [\n \"patient\",\n \"admission\",\n \"emergency\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Radiology Report - Chest X-Ray\",\n \"author\": \"Dr. Bob Lee\",\n \"department\": \"Radiology\",\n \"createdAt\": \"2024-01-15T14:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"final\",\n \"category\": \"diagnostic\",\n \"tags\": [\n \"x-ray\",\n \"chest\",\n \"radiology\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Medication Administration Record\",\n \"author\": \"Nurse Carol Jones\",\n \"department\": \"Pharmacy\",\n \"createdAt\": \"2024-03-20T09:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"treatment\",\n \"tags\": [\n \"medication\",\n \"administration\",\n \"pharmacy\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"Surgical Consent Form\",\n \"author\": \"Dr. David Patel\",\n \"department\": \"Surgery\",\n \"createdAt\": \"2023-12-05T11:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"consent\",\n \"tags\": [\n \"surgery\",\n \"consent\",\n \"patient\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"Annual Security Policy\",\n \"author\": \"IT Security Team\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-28T16:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"compliance\"\n ],\n \"confidentialityLevel\": \"low\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the recent medical documents?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I can retrieve the latest documents for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List recent documents\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show tickets\n\nRephrased Query: Retrieve a list of tickets without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"MKT-001\",\n \"title\": \"Spring Launch Email Blast\",\n \"description\": \"Prepare and send email campaign for spring product line.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"Marketing\",\n \"assignee\": \"Alice\",\n \"createdAt\": \"2025-03-01T09:15:00Z\",\n \"price\": 1500\n },\n {\n \"ticketId\": \"MKT-002\",\n \"title\": \"Social Media Ads Q2\",\n \"description\": \"Design and schedule social media advertisements for Q2.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"Marketing\",\n \"assignee\": \"Bob\",\n \"createdAt\": \"2025-02-20T14:30:00Z\",\n \"price\": 800\n },\n {\n \"ticketId\": \"MKT-003\",\n \"title\": \"Landing Page Optimization\",\n \"description\": \"A/B test landing page variants to improve conversion.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"Marketing\",\n \"assignee\": \"Charlie\",\n \"createdAt\": \"2025-01-15T11:45:00Z\",\n \"price\": 1200\n },\n {\n \"ticketId\": \"MKT-004\",\n \"title\": \"Influencer Partnership\",\n \"description\": \"Negotiate partnership terms with key industry influencers.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"Marketing\",\n \"assignee\": \"Alice\",\n \"createdAt\": \"2025-03-05T08:00:00Z\",\n \"price\": 2500\n },\n {\n \"ticketId\": \"MKT-005\",\n \"title\": \"Content Calendar Q2\",\n \"description\": \"Create and publish the content calendar for the next quarter.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"Marketing\",\n \"assignee\": \"Alice\",\n \"createdAt\": \"2025-03-03T10:20:00Z\",\n \"price\": 900\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"List 10 recent tickets\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Here are the 10 most recent tickets...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": []\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show 58 high-priority open tickets in the Marketing category assigned to Alice\n\nRephrased Query: Retrieve 58 tickets where status is open, priority is high, category is Marketing, and assignee is Alice\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 58,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"Marketing\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"Alice\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "keyword_search", "size": 58, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"Finance Department Quarterly Report Q1 2024\",\n \"author\": \"dr.smith\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-04-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"report\",\n \"tags\": [\n \"quarterly\",\n \"financial\",\n \"2024\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"IT Security Policy Update\",\n \"author\": \"jane.doe\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2023-12-01T12:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"update\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Patient Confidentiality Guidelines\",\n \"author\": \"dr.williams\",\n \"department\": \"Legal\",\n \"createdAt\": \"2022-08-20T15:45:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"confidentiality\",\n \"patient\",\n \"guidelines\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"Remote Work Security Checklist\",\n \"author\": \"alice.lee\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-01-10T08:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"checklist\",\n \"tags\": [\n \"remote\",\n \"security\",\n \"checklist\"\n ],\n \"confidentialityLevel\": \"low\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest approved policies from IT Security?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the approved policy documents from the IT Security department.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all approved documents\",\n \"dsl_type\": \"simple_match_all\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: $List PDFs from Finance department after 2024\n\nRephrased Query: Retrieve approved PDF documents from the Finance department created on or after 2024-01-01\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n },\n \"text\": {\n \"fields\": [\n \"title\",\n \"tags\"\n ],\n \"query\": \"policy\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"Finance\"\n }\n },\n {\n \"range\": {\n \"createdAt\": {\n \"gte\": \"2024-01-01\"\n }\n }\n },\n {\n \"term\": {\n \"fileType\": \"pdf\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "complex_query", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Marketing Campaigns\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-001\",\n \"productId\": \"PRD-1001\",\n \"title\": \"Spring Sale Email Blast\",\n \"description\": \"Create and schedule email campaign for spring sale.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"email\",\n \"assignee\": \"Alice\",\n \"createdAt\": \"2025-10-20T09:15:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Prepare subject lines and copy for spring promotion.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-002\",\n \"productId\": \"PRD-1002\",\n \"title\": \"Social Media Ads for New Product\",\n \"description\": \"Design and launch Facebook and Instagram ads.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"social\",\n \"assignee\": \"Bob\",\n \"createdAt\": \"2025-09-15T14:30:00Z\",\n \"price\": 1500,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Create visual assets and targeting criteria.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n },\n {\n \"ticketId\": \"TCK-003\",\n \"productId\": \"PRD-1003\",\n \"title\": \"Quarterly Marketing Report\",\n \"description\": \"Compile performance metrics for Q3.\",\n \"status\": \"resolved\",\n \"priority\": \"low\",\n \"category\": \"report\",\n \"assignee\": \"Charlie\",\n \"createdAt\": \"2025-08-01T08:00:00Z\",\n \"price\": 0,\n \"documentContentWordsChunked\": [\n {\n \"passage\": \"Gather data from Google Analytics and CRM.\",\n \"embedding\": [\n 0,\n 0,\n 0\n ]\n }\n ]\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show open high-priority marketing tickets assigned to Alice\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, retrieving the tickets that match your criteria.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List all tickets\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: Show open high-priority marketing tickets assigned to Alice\n\nRephrased Query: Retrieve tickets where status is open, priority is high, category is marketing, and assignee is Alice\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"marketing\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"Alice\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Marketing Campaigns", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "filtered_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Academic Articles\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"doc-001\",\n \"title\": \"Advances in Quantum Computing\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Physics\",\n \"createdAt\": \"2023-05-12T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Research\",\n \"tags\": [\n \"quantum\",\n \"computing\",\n \"technology\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-002\",\n \"title\": \"Machine Learning in Healthcare\",\n \"author\": \"Prof. Bob Lee\",\n \"department\": \"Computer Science\",\n \"createdAt\": \"2024-01-20T14:15:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"Review\",\n \"tags\": [\n \"machine learning\",\n \"healthcare\",\n \"AI\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"doc-003\",\n \"title\": \"Economic Impacts of Climate Change\",\n \"author\": \"Dr. Carol Nguyen\",\n \"department\": \"Economics\",\n \"createdAt\": \"2022-11-03T10:00:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Policy\",\n \"tags\": [\n \"climate change\",\n \"economics\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-004\",\n \"title\": \"Ethical Considerations in AI Development\",\n \"author\": \"Prof. David Patel\",\n \"department\": \"Philosophy\",\n \"createdAt\": \"2023-09-15T09:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"Essay\",\n \"tags\": [\n \"AI\",\n \"ethics\",\n \"technology\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"doc-005\",\n \"title\": \"Renewable Energy Sources Overview\",\n \"author\": \"Dr. Eva Martinez\",\n \"department\": \"Engineering\",\n \"createdAt\": \"2024-03-08T11:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"review\",\n \"category\": \"Survey\",\n \"tags\": [\n \"renewable energy\",\n \"sustainability\"\n ],\n \"confidentialityLevel\": \"internal\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you list the latest research papers on AI?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent AI‑related articles in the index...\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show documents\",\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n }\n]\n\nUser Query: Show documents\n\nRephrased Query: List all academic articles without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"should\": [\n {\n \"match_all\": {}\n },\n {\n \"knn\": {\n \"documentContentWordsChunked.embedding\": {\n \"vector\": [\n 0,\n 0,\n 0,\n \"...\"\n ],\n \"k\": 10\n }\n }\n }\n ]\n }\n }\n }\n}" } ]
{ "domain": "Academic Articles", "data_type": "unstructured", "query_type": "hybrid_search", "pattern": "initial", "pattern_type": "keyword_search", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Technical Manuals\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"DOC-001\",\n \"title\": \"IT Security Policy Overview\",\n \"author\": \"alice.smith\",\n \"department\": \"IT Security\",\n \"createdAt\": \"2024-02-15T09:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"security\",\n \"policy\",\n \"overview\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-002\",\n \"title\": \"Remote Work Guidelines\",\n \"author\": \"bob.johnson\",\n \"department\": \"Human Resources\",\n \"createdAt\": \"2023-11-01T14:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"draft\",\n \"category\": \"guideline\",\n \"tags\": [\n \"remote\",\n \"work\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"public\"\n },\n {\n \"documentId\": \"DOC-003\",\n \"title\": \"Finance Department Expense Policy\",\n \"author\": \"carol.wang\",\n \"department\": \"Finance\",\n \"createdAt\": \"2024-06-20T08:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"expense\",\n \"finance\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"confidential\"\n },\n {\n \"documentId\": \"DOC-004\",\n \"title\": \"Network Architecture Manual\",\n \"author\": \"dave.lee\",\n \"department\": \"IT Infrastructure\",\n \"createdAt\": \"2022-09-10T11:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"manual\",\n \"tags\": [\n \"network\",\n \"architecture\"\n ],\n \"confidentialityLevel\": \"internal\"\n },\n {\n \"documentId\": \"DOC-005\",\n \"title\": \"Data Retention Policy\",\n \"author\": \"eve.kumar\",\n \"department\": \"Legal\",\n \"createdAt\": \"2024-01-05T10:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"policy\",\n \"tags\": [\n \"data\",\n \"retention\",\n \"policy\"\n ],\n \"confidentialityLevel\": \"confidential\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Show me the latest security policies.\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here are the most recent approved security policies.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List 10 recent manuals\",\n \"dsl_type\": \"simple_search\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show 25 approved policies from IT Security department\n\nRephrased Query: Retrieve 25 documents where status is approved, category is policy, and department is IT Security\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"hybrid_search_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 25,\n \"from\": 0,\n \"query\": {\n \"hybrid\": {\n \"vector\": {\n \"field\": \"documentContentWordsChunked.embedding\",\n \"query_vector\": [\n 0,\n 0,\n 0\n ],\n \"k\": 25\n },\n \"text\": {\n \"field\": \"documentContentWordsChunked.passage\",\n \"query\": \"policy\"\n },\n \"filter\": {\n \"bool\": {\n \"must\": [\n {\n \"term\": {\n \"status\": \"approved\"\n }\n },\n {\n \"term\": {\n \"department\": \"IT Security\"\n }\n },\n {\n \"term\": {\n \"category\": \"policy\"\n }\n }\n ]\n }\n }\n }\n }\n }\n}" } ]
{ "domain": "Technical Manuals", "data_type": "unstructured", "query_type": "hybrid_search_with_filters", "pattern": "initial", "pattern_type": "sorted_listing", "size": 25, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Medical Records\n\nField Mappings:\n{\n \"properties\": {\n \"documentId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"author\": {\n \"type\": \"keyword\"\n },\n \"department\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"fileType\": {\n \"type\": \"keyword\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"confidentialityLevel\": {\n \"type\": \"keyword\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"documentId\": \"MR-001\",\n \"title\": \"Patient Admission Summary\",\n \"author\": \"Dr. Alice Smith\",\n \"department\": \"Emergency\",\n \"createdAt\": \"2024-09-12T08:30:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"admission\",\n \"tags\": [\n \"triage\",\n \"initial\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-002\",\n \"title\": \"Radiology Report - Chest X-Ray\",\n \"author\": \"Dr. Bob Lee\",\n \"department\": \"Radiology\",\n \"createdAt\": \"2024-09-10T14:15:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"imaging\",\n \"tags\": [\n \"xray\",\n \"chest\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-003\",\n \"title\": \"Discharge Instructions for Diabetes Management\",\n \"author\": \"Nurse Carol Nguyen\",\n \"department\": \"Endocrinology\",\n \"createdAt\": \"2024-09-08T10:00:00Z\",\n \"fileType\": \"docx\",\n \"status\": \"approved\",\n \"category\": \"discharge\",\n \"tags\": [\n \"diabetes\",\n \"follow-up\"\n ],\n \"confidentialityLevel\": \"high\"\n },\n {\n \"documentId\": \"MR-004\",\n \"title\": \"Lab Results - Complete Blood Count\",\n \"author\": \"LabTech Dave Patel\",\n \"department\": \"Laboratory\",\n \"createdAt\": \"2024-09-11T09:45:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"lab\",\n \"tags\": [\n \"cbc\",\n \"routine\"\n ],\n \"confidentialityLevel\": \"medium\"\n },\n {\n \"documentId\": \"MR-005\",\n \"title\": \"Surgical Consent Form - Knee Arthroscopy\",\n \"author\": \"Dr. Eva Martinez\",\n \"department\": \"Orthopedics\",\n \"createdAt\": \"2024-09-07T13:20:00Z\",\n \"fileType\": \"pdf\",\n \"status\": \"approved\",\n \"category\": \"consent\",\n \"tags\": [\n \"surgery\",\n \"knee\"\n ],\n \"confidentialityLevel\": \"high\"\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest medical records?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, I will retrieve the most recent records for you.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"List recent medical records\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ],\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n }\n }\n }\n]\n\nUser Query: Show recent medical records\n\nRephrased Query: List recent medical records without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Medical Records", "data_type": "unstructured", "query_type": "listing", "pattern": "initial", "pattern_type": "sorted_listing", "size": 10, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Project Management Tasks\n\nField Mappings:\n{\n \"properties\": {\n \"ticketId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"ticketId\": \"TCK-1001\",\n \"title\": \"Network latency issue on VPN\",\n \"description\": \"Users experience high latency when connecting via VPN during peak hours.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-12T08:15:30Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1002\",\n \"title\": \"Database backup failure\",\n \"description\": \"Automated nightly backup failed due to insufficient disk space.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"database\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-10T22:45:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1003\",\n \"title\": \"UI glitch on dashboard\",\n \"description\": \"Widgets overlap when screen resolution is set below 1024px.\",\n \"status\": \"closed\",\n \"priority\": \"low\",\n \"category\": \"ui\",\n \"assignee\": \"frontend_team\",\n \"createdAt\": \"2024-09-28T14:20:10Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1004\",\n \"title\": \"Network switch firmware update\",\n \"description\": \"Schedule firmware upgrade for core switches to address security vulnerabilities.\",\n \"status\": \"open\",\n \"priority\": \"high\",\n \"category\": \"network\",\n \"assignee\": \"tech_support\",\n \"createdAt\": \"2024-10-05T09:00:00Z\",\n \"price\": 0\n },\n {\n \"ticketId\": \"TCK-1005\",\n \"title\": \"API rate limit exceeded alerts\",\n \"description\": \"Clients are receiving 429 errors due to misconfigured rate limits.\",\n \"status\": \"in_progress\",\n \"priority\": \"medium\",\n \"category\": \"api\",\n \"assignee\": \"backend_team\",\n \"createdAt\": \"2024-10-01T11:30:45Z\",\n \"price\": 0\n }\n]\n\nChat History:\n[\n {\n \"role\": \"user\",\n \"content\": \"Can you show me the latest open tickets?\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"Sure, here's a query that returns the most recent open tickets.\"\n }\n]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"Show 10 recent tickets\",\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n }\n]\n\nUser Query: List 65 high-priority network tickets assigned to tech support\n\nRephrased Query: Show 65 tickets where status is open, priority is high, category is network, and assignee is tech_support\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing_with_filters\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 65,\n \"from\": 0,\n \"query\": {\n \"bool\": {\n \"must\": [\n {\n \"match_all\": {}\n }\n ],\n \"filter\": [\n {\n \"term\": {\n \"status\": \"open\"\n }\n },\n {\n \"term\": {\n \"priority\": \"high\"\n }\n },\n {\n \"term\": {\n \"category\": \"network\"\n }\n },\n {\n \"term\": {\n \"assignee\": \"tech_support\"\n }\n }\n ]\n }\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Project Management Tasks", "data_type": "structured", "query_type": "listing_with_filters", "pattern": "initial", "pattern_type": "categorical_listing", "size": 65, "from": 0, "is_pagination": false }
[ { "from": "system", "value": "{\n \"Reasoning\": \"high\",\n \"name\": \"OpenSearch DSL Generation Agent\",\n \"task\": \"Generate PERFECT OpenSearch DSL following EXACT template structure and size requirements.\",\n \"context\": \"Use user_query and rephrased_query together. Rephrased_query is main semantic text; retain filters from user_query.\",\n \n \"CRITICAL_RULES\": [\n \"SIZE: Use EXACT size from user query or default 10 - NO OTHER VALUES\",\n \"TEMPLATE: listing WITH filters MUST use listing_with_filters type\",\n \"FILTERS: listing_with_filters uses bool.filter array, NOT bool.must\",\n \"FROM: Default 0 for initial, calculated for pagination\",\n \"STRUCTURE: Follow template structure EXACTLY - no modifications\"\n ],\n \n \"templates\": [\n {\"name\": \"hybrid_search\", \"use_when\": \"Semantic question without filters\"},\n {\"name\": \"hybrid_search_with_filters\", \"use_when\": \"Semantic question with filters\"},\n {\"name\": \"listing\", \"use_when\": \"List ALL documents without ANY filters\"},\n {\"name\": \"listing_with_filters\", \"use_when\": \"List documents WITH filters (must use filter array)\"}\n ],\n \n \"template_selection_logic\": {\n \"step1\": \"Is query semantic (about content/meaning)? β†’ hybrid_* types\",\n \"step2\": \"Is query listing (show/list by field values)? β†’ listing_* types\",\n \"step3\": \"Does query have filters (status, date, author, etc)? β†’ *_with_filters\",\n \"step4\": \"No filters at all? β†’ base type (hybrid_search or listing)\"\n },\n \n \"size_rules\": {\n \"default\": \"10 (when user doesn't specify)\",\n \"explicit\": \"Extract from query: 'show 20', 'get 50', 'list 100'\",\n \"pagination\": \"Keep same as previous query\",\n \"examples\": {\n \"show tickets\": \"size: 10 (default)\",\n \"show 25 tickets\": \"size: 25 (explicit)\",\n \"list 100 documents\": \"size: 100 (explicit)\",\n \"next page\": \"size: same as previous\"\n }\n },\n \n \"filter_structure\": {\n \"listing_with_filters\": {\n \"correct\": {\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n },\n \"WRONG\": {\n \"query\": {\n \"bool\": {\n \"must\": [\n {\"term\": {\"status\": \"Open\"}},\n {\"term\": {\"priority\": \"High\"}}\n ]\n }\n }\n }\n }\n },\n \n \"defaults\": {\n \"result_size\": 10,\n \"from\": 0,\n \"keyword_boost\": 4.0,\n \"neural_boost\": 3.5,\n \"neural_k\": 60,\n \"inner_hits_size\": 3\n },\n \n \"response_format\": {\n \"dsl_type\": \"EXACT: hybrid_search | hybrid_search_with_filters | listing | listing_with_filters\",\n \"dsl_query\": \"Complete OpenSearch DSL matching template structure EXACTLY\"\n }\n}" }, { "from": "human", "value": "Domain Name: Product Catalog\n\nField Mappings:\n{\n \"properties\": {\n \"productId\": {\n \"type\": \"keyword\"\n },\n \"title\": {\n \"type\": \"text\"\n },\n \"description\": {\n \"type\": \"text\"\n },\n \"status\": {\n \"type\": \"keyword\"\n },\n \"priority\": {\n \"type\": \"keyword\"\n },\n \"category\": {\n \"type\": \"keyword\"\n },\n \"assignee\": {\n \"type\": \"keyword\"\n },\n \"createdAt\": {\n \"type\": \"date\"\n },\n \"price\": {\n \"type\": \"float\"\n },\n \"documentContentWordsChunked\": {\n \"type\": \"nested\",\n \"properties\": {\n \"passage\": {\n \"type\": \"text\"\n },\n \"embedding\": {\n \"type\": \"knn_vector\",\n \"dimension\": 768\n }\n }\n }\n }\n}\n\nSample Documents:\n[\n {\n \"productId\": \"P001\",\n \"title\": \"Wireless Mouse\",\n \"description\": \"Ergonomic wireless mouse with 2.4GHz connectivity.\",\n \"status\": \"available\",\n \"priority\": \"medium\",\n \"category\": \"electronics\",\n \"assignee\": \"warehouse1\",\n \"createdAt\": \"2023-08-15T10:20:30Z\",\n \"price\": 29.99,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P002\",\n \"title\": \"Bluetooth Headphones\",\n \"description\": \"Over-ear headphones with noise cancellation.\",\n \"status\": \"available\",\n \"priority\": \"high\",\n \"category\": \"electronics\",\n \"assignee\": \"warehouse2\",\n \"createdAt\": \"2023-07-10T08:15:00Z\",\n \"price\": 79.5,\n \"documentContentWordsChunked\": []\n },\n {\n \"productId\": \"P003\",\n \"title\": \"Stainless Steel Water Bottle\",\n \"description\": \"1L insulated bottle keeps drinks cold for 24h.\",\n \"status\": \"out_of_stock\",\n \"priority\": \"low\",\n \"category\": \"home\",\n \"assignee\": \"warehouse3\",\n \"createdAt\": \"2023-09-01T12:00:00Z\",\n \"price\": 19,\n \"documentContentWordsChunked\": []\n }\n]\n\nChat History:\n[]\n\nPrevious DSL History:\n[\n {\n \"user_query\": \"list 10 products\",\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"size\": 10,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n }\n }\n }\n]\n\nUser Query: Show 40 products\n\nRephrased Query: list 40 products without any filters\n\nAVAILABLE TEMPLATES:\n\nTEMPLATE: hybrid_search\nUse for: Semantic questions WITHOUT filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"queries\": [\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"match\": {\n \"documentContentWordsChunked.passage\": {\n \"query\": \"{{search_query}}\",\n \"boost\": {{keyword_boost}}\n }\n }\n },\n \"inner_hits\": {\n \"size\": {{inner_hits_size}},\n \"_source\": [\"documentContentWordsChunked.passage\"]\n }\n }\n },\n {\n \"nested\": {\n \"path\": \"documentContentWordsChunked\",\n \"score_mode\": \"max\",\n \"query\": {\n \"neural\": {\n \"documentContentWordsChunked.embedding\": {\n \"query_text\": \"{{search_query}}\",\n \"k\": {{neural_k}},\n \"boost\": {{neural_boost}}\n }\n }\n }\n }\n }\n ]\n }\n }\n}\n\nTEMPLATE: hybrid_search_with_filters\nUse for: Semantic questions WITH filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"hybrid\": {\n \"filter\": {{filters_object}},\n \"queries\": [... same as hybrid_search ...]\n }\n }\n}\n\nTEMPLATE: listing\nUse for: List ALL documents WITHOUT ANY filters\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\"match_all\": {}},\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nTEMPLATE: listing_with_filters\nUse for: List documents WITH filters\nIMPORTANT: Use \"filter\" array inside bool, NOT \"must\"\n{\n \"_source\": {\"excludes\": [\"documentContentWordsChunked\",\"documentContentWords\"]},\n \"size\": {{result_size}},\n \"from\": {{from}},\n \"query\": {\n \"bool\": {\n \"must\": [{\"match_all\": {}}],\n \"filter\": [\n {\"term\": {\"status\": \"value\"}},\n {\"term\": {\"priority\": \"value\"}},\n {\"range\": {\"createdAt\": {\"gte\": \"date\"}}}\n ]\n }\n },\n \"sort\": [{\"createdAt\": {\"order\": \"desc\"}}]\n}\n\nSIZE EXAMPLES:\nβœ… \"show tickets\" β†’ size: 10 (default)\nβœ… \"show 20 tickets\" β†’ size: 20 (explicit in query)\nβœ… \"list 50 documents\" β†’ size: 50 (explicit in query)\nβœ… \"next page\" β†’ size: same as previous query\n❌ \"show tickets\" β†’ size: 73 (WRONG - arbitrary)\n❌ \"list policies\" β†’ size: 15 (WRONG - not specified)" }, { "from": "gpt", "value": "{\n \"dsl_type\": \"listing\",\n \"dsl_query\": {\n \"_source\": {\n \"excludes\": [\n \"documentContentWordsChunked\",\n \"documentContentWords\"\n ]\n },\n \"size\": 40,\n \"from\": 0,\n \"query\": {\n \"match_all\": {}\n },\n \"sort\": [\n {\n \"createdAt\": {\n \"order\": \"desc\"\n }\n }\n ]\n }\n}" } ]
{ "domain": "Product Catalog", "data_type": "structured", "query_type": "listing", "pattern": "pagination", "pattern_type": "previous_page", "size": 40, "from": 0, "is_pagination": true }