I’m using the SPH_MATCH_EXTENDED2 match mode with Sphinx 0.9.9 and I want to write a search query that finds all records that have anything in a particular field. I have tried the following with no success:
@MyField *
@MyField !""
I figure that I can add a field to my index that specifically checks for this and query against that, but I’d prefer to have more flexibility than that–it would be really nice to be able to do this through the query syntax.
Any thoughts?
You can do it without updating/changing the db — just by modifying the sql_query your index/source is built off of. e.g.
Then running off of a previous poster’s comment, just use the negation in the sphinx query.
Alternatively, you could create a dynamic sphinx attribute you could filter against. e.g.
Then make sure you filter on
title_is_not_blank=1for every search.Or, depending on your application, if you never need ones with blank content, just eliminate then with the sql_query
WHEREclause. e.g.