System info: [Include InfluxDB version, operating system name, and other relevant details]
Linux Mint 17.3 Cinnamon 64-bit
InfluxDB shell 0.12.2
Steps to reproduce:
The where clause sometimes returns no results even though it should.
Enter this data in the database
name: member_info
-----------------
time clanRank clan_name clan_tag donations donationsReceived expLevel league member_name member_tag previousClanRank role trophies
1461512944213232128 35 "SkeletonFarmers" "#YPYR9GQY" 2680 2188 122 Gold League II "sk" "#202GPUY8C" 44 leader 1638
1461513001517127936 35 "SkeletonFarmers" "#YPYR9GQY" 2680 2188 122 Gold League II "sk" "#202GPUY8C" 44 leader 1638
1461513009273016064 35 "SkeletonFarmers" "#YPYR9GQY" 2680 2188 122 Gold League II "sk" "#202GPUY8C" 44 leader 1638
After entering the data if I run
> select * from member_info where member_name = 'sk'
I get no response
However, If I run
> select * from member_info where member_name =~ /sk/
I get full result
And running this also results in all rows
> select * from member_info where member_name =~ /.*sk.*/
So, seems like there is some problem in string matching when = is used in where_clause.
@saadusman17 can you convert the data you input into the line protocol? I'm unable to make a simple reproducer of what you did and reproduce your results. The data in line protocol format that I can send to /write would greatly help to allow me to try and reproduce the output.
Thanks!
Here is an example data to insert in line protocol:
member_info,clan_name="SkeletonFarmers",clan_tag="#YPYR9GQY",member_name="waveslasher",member_tag="#G9C9RR9G" league="Master League II",expLevel=109,trophies=2866,role="coLeader",donationsReceived=61,donations=86,clanRank=1,previousClanRank=1 1462206042543982080
I am posting it using python requests on following URL:
http://localhost:8086/write?db=dbname
And after inserting this data, I am trying this in the query option
select * from member_info where member_name = "waveslasher"
I get empty result
And if I try following, I get the inserted record back:
select * from member_info where member_name = "waveslasher"
Thanks,
Saad
Are you using single quotes or double quotes? Strings are surrounded by single quotes while variables are surrounded by double quotes.
Yes, they are surrounded by single quotes when I am entering data. Here is the code which enters data:
db_insertion_string = ('member_info'+',clan_name="'+clan_info["name"] +
'",clan_tag="' + clan_info["tag"] +
'",member_name="' + member_name +
'",member_tag="'+member["tag"] +
'" league="' + member["league"]["name"] +
'",expLevel='+str(member["expLevel"]) +
',trophies='+str(member["trophies"]) +
',role="'+str(member["role"]) +
'",donationsReceived='+str(member["donationsReceived"]) +
',donations='+str(member["donations"]) +
',clanRank='+str(member["clanRank"]) +
',previousClanRank='+str(member["previousClanRank"]) +
' '+str(time_in_nanoseconds))
The insertion works fine. The data does get inserted in the database
When querying I get no results even if I use single quotes such as:
select * from member_info where member_name = 'waveslasher'
For me it only works with regex notation.
Thanks,
Saad
Thanks,
Saad
I think I figured it out,
this notation returns me results:
select * from member_info where member_name = '\"waveslasher\"'
Also this one works:
select * from member_info where member_name = '"waveslasher"'
So, it seems like double quotes are being inserted as part of the string itself! What would be correct notation for data insertion then?
member_info,clan_name='SkeletonFarmers',clan_tag='#YPYR9GQY',member_name='waveslasher',member_tag='#G9C9RR9G' league='Master League II',expLevel=109,trophies=2866,role='coLeader',donationsReceived=61,donations=86,clanRank=1,previousClanRank=1 1462206042543982080
Ah, I understand now. You do not need to use quotes to insert with tags. This is fine:
member_info,member_name=waveslasher
From here:
The key is the measurement name and any optional tags separated by commas. Measurement names, tag keys, and tag values must escape any spaces or commas using a backslash (
\). For example:\and\,. _All tag values are stored as strings and should not be surrounded in quotes_.
I'm going to close this since it seems to be user error rather than a bug. Please open an issue with influxdata/docs.influxdata.com if you think we can clarify this at all. Thanks.
Thank you very much for the help.
Most helpful comment
Are you using single quotes or double quotes? Strings are surrounded by single quotes while variables are surrounded by double quotes.