Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e30BK-0007al-GS for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Oct 2017 13:39:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e30BJ-00069Z-OL for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Oct 2017 13:39:17 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e309l-0003Pn-62 for pgsql-hackers@postgresql.org; Fri, 13 Oct 2017 13:37:41 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e309h-00058f-Fm for pgsql-hackers@postgresql.org; Fri, 13 Oct 2017 13:37:40 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id CC04D21C1EE7; Fri, 13 Oct 2017 16:37:34 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from PostgresPro-A-Chernyshov (unknown [31.173.148.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 6AC7521C1E66; Fri, 13 Oct 2017 16:37:34 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1507901854; bh=mZ4KBPeVJpihPr8w/FVqF/dp7U0lfcIEr9DpRYsItwg=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=U99abxqTKi7Nx5vy3lsjoijuoa/5iCOKSxbp7T7UQWbDCwHhOEtUMG/O4DM38HDl+ CBrMNN3Urzj/r/pMqD95RcaIMh1NLbSC48grSJcaHg6GLyPreS3UFp1iTgj8ggXrbh Cm7KbD6fLoiZNwQ4H/9eZrqvxwGle03Apf/oMnMM= Date: Fri, 13 Oct 2017 16:37:32 +0300 From: Alexey Chernyshov To: Victor Drobny Cc: Thomas Munro , Robert Haas , pgsql-hackers@postgresql.org Subject: Re: new function for tsquery creartion Message-ID: <20171013163732.1bb85695@PostgresPro-A-Chernyshov> In-Reply-To: <69234700d26674fc7c171e48b850824c@postgrespro.ru> References: <69234700d26674fc7c171e48b850824c@postgrespro.ru> Organization: Postgres Pro X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hi all, I am extending phrase operator is such way that it will have syntax that means from n to m words, so I will use such syntax () further. I found that a AROUND(N) b is exactly the same as a <-N,N> b and it can be replaced while parsing. So, what do you think of such idea? In this patch I have noticed some unobvious behavior. # select to_tsvector('Hello, cat world!') @@ queryto_tsquery('cat AROUND(1) cat') as match; match ------- t cat AROUND(1) cat is the same is "cat <1> cat || cat <0> cat" and: # select to_tsvector('Hello, cat world!') @@ to_tsquery('cat <0> cat'); ?column? ------- t It seems to be a proper logic behavior but it is a possible pitfall, maybe it should be documented? But more important question is how AROUND() operator should handle stop words? Now it works as: # select queryto_tsquery('cat <2> (a AROUND(10) rat)'); queryto_tsquery ------------------ 'cat' <12> 'rat' (1 row) # select queryto_tsquery('cat <2> a AROUND(10) rat'); queryto_tsquery ------------------------ 'cat' AROUND(12) 'rat' (1 row) In my opinion it should be like: cat <2> (a AROUND(10) rat) == cat <2,2> (a <-10,10> rat) == cat <-8,12> rat cat <2> a AROUND(10) rat == cat <2,2> a <-10,10> rat = cat <-8, 12> rat Now operator can be replaced with combination of phrase operator , AROUND(), and logical operators, but with operator it will be much painless. Correct me, please, if I am wrong. -- Alexey Chernyshov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers