Search code examples
influxdb

Where clause on tag keys in influxdb does not work


I see some strange behavior in 0.9.6.1. The issue is when i query a field without a where clause, it works but when i add "WHERE" in the statement for a tag key, it gives me empty results.

for ex,

select successful, merchant_id from session_metrics_new limit 5

name: session_metrics_new

time                    successful      merchant_id
1453975732000000000     1               bms
1453975733000000000     1               snp
1453975735000000000     1               bms
1453975735000000000     1               snp
1453975739000000000     1               bms

but this does not work

select successful, merchant_id from session_metrics_new where merchant_id =~ /bms/ limit 5

Here, successful is a field key while merchant_id is a tag key. I do not know if this a bug or the way i have stored data. Please help


Solution

  • You're using the regex syntax.

    I tried a query on my DB with the same syntax that you used, and I got a result set without a problem. The only problem I see there is if successful is also a TAG rather than a FIELD. But in that case you should get the following exception:

    Server returned error: statement must have at least one field in select clause

    Are you executing this query through the InfluxDb admin interface or through a 3rd party library for say Java, C#, NodeJs or something like that?

    Try a simple where clause instead if you think you'll know the full value of merchant_id field all the time, it's slightly different (it doesn't do pattern matching, but it matches the whole value from the field), that should work and it should even be faster:

    select successful, merchant_id from session_metrics_new where merchant_id = 'bms' limit 5