From issues-return-49100-archive-asf-public=cust-asf.ponee.io@camel.apache.org Fri Feb 2 10:05:04 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id D6F22180608 for ; Fri, 2 Feb 2018 10:05:04 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C6757160C49; Fri, 2 Feb 2018 09:05:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E8FE5160C41 for ; Fri, 2 Feb 2018 10:05:03 +0100 (CET) Received: (qmail 66744 invoked by uid 500); 2 Feb 2018 09:05:03 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 66729 invoked by uid 99); 2 Feb 2018 09:05:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Feb 2018 09:05:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id AD54EC0505 for ; Fri, 2 Feb 2018 09:05:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.511 X-Spam-Level: X-Spam-Status: No, score=-109.511 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id jXhIio1eZ5sO for ; Fri, 2 Feb 2018 09:05:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 0C09A5FAC8 for ; Fri, 2 Feb 2018 09:05:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7F751E026E for ; Fri, 2 Feb 2018 09:05:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 1656921E82 for ; Fri, 2 Feb 2018 09:05:00 +0000 (UTC) Date: Fri, 2 Feb 2018 09:05:00 +0000 (UTC) From: "Claus Ibsen (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CAMEL-12034) camel-elasticsearch5 - Search Operation: If Map or String is used in Message Body, "size" and "from" parameters are always ignored MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-12034?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Claus Ibsen updated CAMEL-12034: -------------------------------- Summary: camel-elasticsearch5 - Search Operation: If Map or String is used in Message Body, "size" and "from" parameters are always ignored (was: Search Operation: If Map or String is used in Message Body, "size" and "from" parameters are always ignored (lost while conversion).) > camel-elasticsearch5 - Search Operation: If Map or String is used in Message Body, "size" and "from" parameters are always ignored > ---------------------------------------------------------------------------------------------------------------------------------- > > Key: CAMEL-12034 > URL: https://issues.apache.org/jira/browse/CAMEL-12034 > Project: Camel > Issue Type: Bug > Components: camel-elasticsearch5 > Affects Versions: 2.20.1 > Reporter: Radoslav Cincala > Assignee: Andrea Cosentino > Priority: Minor > Fix For: 2.20.3, 2.21.0 > > > Hi, > I am using camel-elasticsearch5 component of Camel 2.20.1. > I have found and issue. The description follows. > *If you use Map or String in message body for SEARCH operation, "size" and "from" parameters are always ignored hence you always get just default 10 results.* > For example - if your map contains query like this: > (in terms of simplicity - following is String representation of the map): > {code} > {size=50, query={query_string={query=status:ACTIVE}}, from=0} > {code} > Issue I suspect is present in class: _org.apache.camel.component.elasticsearch5.converter.ElasticsearchActionRequestConverter_ > and its method > _public static SearchRequest toSearchRequest(Object queryObject, Exchange exchange)_ > {code} > // line 191... > if (queryObject instanceof Map) { > Map mapQuery = (Map)queryObject; > // Remove 'query' prefix from the query object for backward compatibility > if (mapQuery.containsKey(ElasticsearchConstants.ES_QUERY_DSL_PREFIX)) { > mapQuery = (Map)mapQuery.get(ElasticsearchConstants.ES_QUERY_DSL_PREFIX); > } > try { > XContentBuilder contentBuilder = XContentFactory.contentBuilder(XContentType.JSON); > queryText = contentBuilder.map(mapQuery).string(); > } catch (IOException e) { > LOG.error(e.getMessage()); > } > } > // queryText then used on line 220... > searchSourceBuilder.query(QueryBuilders.wrapperQuery(queryText)); > searchRequest.source(searchSourceBuilder); > return searchRequest; > {code} > Inner if condition basically extracts only query part from the map > {code} > query={query_string={query=status:ACTIVE} > {code} > and *"size" and "from" get lost from the query* > {code} > // line 194... > if (mapQuery.containsKey(ElasticsearchConstants.ES_QUERY_DSL_PREFIX)) { > mapQuery = (Map)mapQuery.get(ElasticsearchConstants.ES_QUERY_DSL_PREFIX); > // ...where ElasticsearchConstants.ES_QUERY_DSL_PREFIX = "query" > } > {code} > Same issue is with usage of the String in the message body: > {code} > // line 203 > } else if (queryObject instanceof String) { > queryText = (String)queryObject; > ObjectMapper mapper = new ObjectMapper(); > try { > JsonNode jsonTextObject = mapper.readValue(queryText, JsonNode.class); > JsonNode parentJsonNode = jsonTextObject.get(ElasticsearchConstants.ES_QUERY_DSL_PREFIX); > if (parentJsonNode != null) { > queryText = parentJsonNode.toString(); > } > } catch (IOException e) { > LOG.error(e.getMessage()); > } > } > {code} > Only workaround for this is to use *SearchRequest* object in a message body where you can explicitly set "size" and "from" on SearchSourceBuilder object. For example: > {code} > SearchRequest searchRequest = new SearchRequest("my_index") > .types("my_type") > .source(new SearchSourceBuilder().query(QueryBuilders.wrapperQuery("my:query")) > .size(50).from(0)); > {code} > I don't know what was the developer's intention for having such a condition which removes these parameters from the query. > Thank you very much in advance if anybody can have a look and verify if this is a valid concern. -- This message was sent by Atlassian JIRA (v7.6.3#76005)