Sphinx: combining phrase and field-end operator - sphinx

When combining phrase and field-end operators, Sphinx (2.0.4-release) seems to ignore the field-end operator.
E.g. when searching for
"^some phrase$"
it will correctly find "some phrase", but it will also find "some phrase with more words", thus ignoring the field-end operator.
Is there a way to fix this?

There's a bug in Sphinx until version 2.0.5-release.
As a workaround use space after the field-end operator, so
"^some phrase$"
will become
"^some phrase$ "

Related

Regrex query in DB2-LUW

I need a regrex query to match any string having given character. So i tried for example
SELECT wt.CHGUSER FROM "CDB"."WTBALL" wt where REGEXP_LIKE (wt.CHGUSER, '^\d*115*$');
So i am expecting to fetch all the strings having 115 somewhere in between each string. I tried many combinations but i am getting empty column or weird combination.
Are you sure You need a regex? You write "all the strings having 115 somewhere in between each string", but test for a all-digit string with "115" somewhere...
Btw. this could be done also without regex:
WHERE LOCATE('115', wt.CHGUSER) > 0
AND TRANSLATE(wt.CHGUSER, '', '0123456789') --if You really want to test all-digit string
why not use the native "LIKE" expression?
where wt.CHGUSER like '%115%'
This will give different results than your regexp because your expression is looking for '115' so long as there is a digit immediate before and after it. A more generic regexp, which matches your question, would be '.*115.*'
What about -
REGEXP_LIKE (wt.CHGUSER, '^*\d115\d*$');

Microsoft graph Mail Search Strict value

I have an issue with the search parameters. I want to pass a phrase in my query. For exemple i'm looking for emails where the subject is "Test 1".
For this i'm doing a get on this ressource.
https://graph.microsoft.com/v1.0/me/messages?$search="subject:Test 1"
But the behaviour of this query is : Looking for mails that contains "Test" in the subject OR 1 in any other fields.
Refering to the KQL Syntax
A phrase (includes two or more words together, separated by spaces; however, the words must be enclosed in double quotation marks)
So, to do what i want i have to put double quotes (") around my phrase to do a strict value search. Like below
subject:"Test 1"
The problem it's at this point. Microsoft graph api already use double quotes (") after the parameters $search.
?$search="Key words"
So I can't do what is mentioned in the KQL doc.
https://graph.microsoft.com/v1.0/me/messages?$search="subject:"Test 1""
It's throwing an error :
"Syntax error: character '1' is not valid at position 15 in '\"subject:\"test 1\"\"'.",
It's an expected behaviour. I was pretty sure it will not work.
If someone has any suggestions for a solution or a workaround, I'm a buyer.
What I've already tried so far :
Use simple quote
Remove the quotes right after $select=
Remove the subject part $select="Test 1", same behaviour as the first request mentioned in this post. It will looks for emails that contain "test" or "1".
Best regards.
EDIT :
After sasfrog's anwser :
I used $filter : It works well with simple operator AND, OR.I have some errors by using the Not Operator. And btw you have to use the orderby parameter to show the result by date and add the field in filter parameters.
Exemple 1 (working, what I asked for first) :
https://graph.microsoft.com/v1.0/me/messages/?$orderby=receivedDateTime desc &$filter=receivedDateTime ge 1900-01-01T00:00:00Z AND contains(subject,'test 1')
Exemple 2 (not working)
https://graph.microsoft.com/v1.0/me/messages/?$orderby=receivedDateTime desc &$filter=(receivedDateTime ge 1900-01-01T00:00:00Z AND contains(subject,'test 1')) NOT(contains(from/EmailAddress/address,[specific address]))
EDIT 2
After some test with the filter parameters.
The NOT operator is still not working so to workaround use "ne" (non-equals)
the example 2 becomes :
https://graph.microsoft.com/v1.0/me/messages/?$orderby=receivedDateTime desc&$filter=(receivedDateTime ge 1900-01-01T00:00:00Z AND contains(subject,'test 1')) AND (from/EmailAddress/address ne [specific address])
UPDATE : OTHER SOLUTION WITH $search
Using $filter is great but it looks like it was sometimes pretty slow. So I found a workaround aboutmy issue.
It's to use AND operator between all terms.
Exemple 4 :
I'm looking for the mails where the subject is test 1;
Let value = "test 1". So you have to splice it by using space separator. And after write some code to manipulate this array, to obtain something like below.
$search="(subject:test AND subject:1)"
The brackets can be important if you use a multiple fields search. And VoilĂ .
Not sure if it's sufficient for what you're doing, but how about using the contains function within a filter query instead:
https://graph.microsoft.com/v1.0/me/messages?$filter=contains(subject,'Test 1')
Sounds like you're already looking at the doco but here it is just in case.
Update also, this worked for me using the search method:
https://graph.microsoft.com/v1.0/me/messages?$search="subject:'Test 1'"

Sphinx query before and after a term

Is it possible to set up a query in sphinx with a term that has to either also match a word before OR after?
(TermBefore) (Term) (TermAfter)
so that both
TermBefore Term
Term TermAfter
would match but
Term
does not?
The proximity search operator is pretty much designed for this
"Term TermAfter"~2
http://sphinxsearch.com/docs/current.html#extended-syntax
Ah, I thought you meant 'TermAfter' to be actully be the same word, just that it can be before or after.
But if two different terms, possibly the easiest is just to do:
"TermBefore Term" | "Term TermAfter"
Just simple phrase operator, where either phrase must match.
Edit again:
If dont want the matchs adjecent use Strict order operator, rather htna phrase operator...
(TermBefore << Term) | (Term << TermAfter)

Postgres / SQL::Abstract "Not In Range" Operation

Postgres has some cool range operators for handling ranges:
http://www.postgresql.org/docs/devel/static/functions-range.html
...but doesn't appear to have anything to handle 'not' being in a range. For instance, the #> operator means 'contains element' or 'contains range'. But equally helpful would be the !#> operator, which doesn't seem to exist.
If I'm trying to say "query where date is not in range", is there any solution other than using a conditional expression? I'm using SQL::Abstract, which doesn't support expressions without using literal SQL, which I would like to avoid.
I do it this way
FALSE = INT4RANGE(1,5) #> 5
I would recommend using NOT BETWEEN date AND date.
Sorry, you may still end up using a SQL literal.

What should the ... operators be called?

The ... operators are identical to the range operator (..) in list context and nearly identical to the flip-flop operator (..) in scalar context, but calling them the range operator and the flip-flop operator seems wrong since those names are more commonly associated with .., which has slightly different behavior (in scalar context at least).
For now, I am calling them the alternate range/flip-flop operator.
Since ... is identical to .. in list context I'd call it the same thing: the range operator. Giving it another name would imply that it does something different. If I needed to distinguish it from .. for some reason I'd probably call it the "three-dot syntax for the range operator."
If I wanted to mess with people I'd tell them that it's "for really long ranges." ;)
In scalar context I've generally called ... the "sed-like flip-flop operator" because of the reference to sed behavior in the documentation, but I don't like that for a name. How about the "long flip-flop" operator? The mnemonic is that ... is one dot longer and takes one more cycle to evaluate the right operand.
I like to think of it as the ellipses operator--which makes it clear that it's about multiple dots (".." or "...") and less confusion about it's function.
In 5.11, where a term is expected (due to a bug, currently only at the beginning of a statement), ... is the yada yada operator.
Otherwise, in list context, ... is the range operator (though I would regard it as code smell, since the code seems to be wanting something different than .. but isn't in fact any different).
Otherwise, it is the flip-flop operator, one flavor thereof. If I had to give it an adjective, I would say the sed-like flip-flop operator. In the perl6 spec it (well, the fff replacement, anyway) is called "flipflop (sed style)". If I wanted to give it a name not based on another language, I'd start by getting the perl6 spec updated, then update the perl5 doc.