Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BALANCED parentheses filter query will trigger "Could not parse the filter query. #1764

Open
IonCimpoiesu opened this issue Jun 1, 2024 · 2 comments

Comments

@IonCimpoiesu
Copy link

IonCimpoiesu commented Jun 1, 2024

Description

As the tittle says, the following multi_search returns the message Could not parse the filter query.

Steps to reproduce

Not working

{
    "searches": [
        {
            "collection": "Mantis",
            "exclude_fields": "",
            "filter_by": "type:=chunk  \u0026\u0026 labeling.count :\u003e 0 \u0026\u0026 labels: [\"gold\",\"Gold\",\"Precious Metals\",\"hard assets\",\"Metals\",\"Commodities\",\"Metalicity\",\"commodity\",\"Industrial Metals\",\"Investors wanting hard assets\",\"Raw materials\",\"Rare earth elements\",\"Golden Metal Resources\",\"Aurum Resources\",\"Materials\",\"Commodity\",\"Financial markets\",\"financial markets\",\"financial\",\"Rare Earth Elements\",\"finance\",\"Consumer Goods\",\"The prospect of higher-for-longer U.S. rates took some shine off the yellow metal\",\"Energy commodity\",\"Commodities market\",\"Financials\",\"Commodity prices\",\"Precious Metals Market\",\"Commodity market\",\"Financial\",\"commodity prices\",\"Commodity Prices\",\"financial market\",\"Commodity Market\",\"gold equivalent ounces\",\"Luxury Goods\",\"Commodity Trading\",\"Markets\",\"Commodities Trading\",\"Financial Markets\",\"Stocks\",\"Economy\",\"economy\",\"Metals market\",\"Gold Reserve\",\"GoldMining\",\"Gold prices\",\"Equities\",\"Gold Mining\",\"Resources\",\"Currency\",\"Finance\",\"Global financial markets\",\"Currency markets\",\"Sichuan Rongda Gold\",\"Wing Fung Precious Metals\",\"Spanish Mountain Gold\",\"Investing\",\"stock market\",\"Financial Market\",\"Economic\",\"Investment\",\"Currency market\",\"Gold mining\",\"Silver\",\"market\",\"Financial services\",\"Mining\",\"Mining Exploration\",\"The stock market is currently trading at a certain level\",\"Industrials\",\"Banking\",\"Financial sector\",\"Before July\",\"Aurumin\",\"Lundin Gold\",\"financial services\",\"5.48 grams per tonne\",\"Golden Energy and Resources\",\"Palladium\",\"E79 Gold Mines\",\"Geology\",\"Cryptocurrency\",\"Zodiac Gold\",\"Investments\",\"Energy\",\"Harmony Gold\",\"Gold dipped 0.25% to $2,372.28 an ounce\",\"Investors still want hard assets and Lewis says he doesn't see this changing in the short-term.\",\"China Nonferrous Gold\",\"SPDR Gold Shares(GLD)\",\"mining\",\"metal prices\",\"Stock market\",\"Financial Industry\",\"Price Movement\"] \u0026\u0026 labeling.strategy :!= undefined",
            "q": "gold",
            "query_by": "labels, metadata.title, text",
            "query_by_weights": "10, 3, 5",
            "vector_query": "embedding:([-0.032667983,0.0039473767,0.005812002,0.04523945,-0.017691698,-0.053429432,0.042401485,0.041330967,-0.000029027671,0.009384659,0.025088683,-0.022720717,0.020883393,0.03850513,0.08746865,0.058399133,0.035951823,-0.038359668,-0.15884201,0.084598325,0.047194865,-0.057555784,-0.07196709,-0.086945824,0.008614092,0.021483444,0.015626272,-0.034421194,-0.03548226,-0.109142885,-0.032563172,0.007977602,0.03524069,0.015495696,0.008870208,-0.009546201,-0.012514912,0.025638081,-0.058277216,0.010343512,0.04379806,-0.00034003714,-0.068421915,0.0150450645,0.02343076,0.011689481,0.014109681,-0.010791189,0.013985279,-0.02080013,-0.030339437,0.025625715,0.0024396158,0.052652556,0.058004726,0.049715724,-0.0087079415,0.014394205,0.007854934,0.010127793,0.023935692,0.039525602,-0.15001552,0.050422587,0.010919137,0.02586476,0.0018362217,-0.0033862074,-0.049125146,0.077616565,0.07222657,0.014562906,-0.017269742,0.0601641,0.007429748,-0.0056630983,0.021926256,-0.029780675,0.054912437,0.0063516586,-0.07854355,-0.013342344,-0.064957745,0.018431142,-0.0128257135,-0.06773294,0.011004469,0.021922225,0.056856647,0.016196834,0.024453003,-0.048909172,-0.0070780385,-0.010447104,-0.04354541,-0.027985368,0.013559723,-0.018492686,0.003382786,0.15977976,0.03216482,0.028211659,0.027048795,-0.060040202,0.004624014,0.02439269,-0.02946296,-0.0187307,-0.024048716,-0.006922771,0.040415805,-0.02534655,0.10939681,-0.07549922,-0.026515221,0.05527791,0.024130782,0.00838552,0.0010583013,-0.0011188317,-0.05551308,-0.02542888,0.0025157118,-0.043395597,0.04095863,-0.044930782,0.05189125,0.081526294,-0.06696412,0.09490119,0.04816166,-0.094185375,-0.08406544,-0.02039201,0.0030506682,0.003919931,0.01504405,-0.0249369,0.07679988,0.04635927,-0.090303525,-0.11673996,-0.022063518,-0.07246459,0.0034546363,0.06749547,-0.04145805,-0.031169917,-0.059089318,-0.07506823,-0.056012195,0.0042568846,0.041262504,0.022970384,-0.029883662,0.041901477,0.08016807,0.048634626,-0.057715677,-0.020264108,0.065392464,0.019997764,0.0105482815,0.104196265,0.0255159,-0.107133456,-0.08207006,-0.039118852,-0.025207996,-0.039198443,0.043615885,0.09395943,-0.09045545,0.03103667,0.10145533,-0.044690978,0.004590788,0.032001376,-0.01794705,0.02426285,-0.010811691,-0.0033280079,0.010785056,0.07732925,-0.031716455,-0.089458,-0.00735471,0.03921279,0.054529972,-0.04367007,0.05383027,-0.0013836556,-0.041233648,0.04319662,-0.04512032,-0.023969475,0.004822958,-0.0016430175,-0.03286865,-0.02525829,0.06862477,-0.03217821,-0.009196379,0.04908565,0.031021578,0.027052633,-0.03570627,0.02792165,-0.0025508278,0.023709562,0.008722117,0.02160538,-0.0015203725,0.016102342,-0.020720106,-0.10137227,-0.0001025196,0.00069947774,-0.03027042,0.019991303,0.0128058,-0.056802966,-0.042539794,-0.26045668,0.021828528,-0.011513137,-0.026258873,0.0059395838,0.02361498,0.023611123,-0.015242678,0.09454663,0.09794106,0.04400122,0.012998303,-0.022556363,0.016688332,0.029031899,0.061771896,0.03214569,-0.050796553,0.032054406,0.004151947,-0.008297203,0.003868991,-0.0029843661,-0.08949367,0.041237622,0.035347622,0.20319663,0.09467109,-0.10564916,-0.067829,0.00792331,-0.0285371,-0.06758674,-0.07445657,0.009135262,0.0051551145,0.022373397,0.084889196,-0.05802085,0.015481831,-0.01030594,0.01948649,-0.054303195,0.019580485,0.03654844,-0.00401584,0.04929166,-0.03504597,0.002041342,0.10406345,-0.0028440384,-0.0074305264,0.082981504,0.03256745,-0.010653614,-0.038280837,-0.060251635,-0.01584224,-0.02542106,0.03576775,-0.0022685593,-0.024608321,0.0011773182,0.039372332,0.041638453,-0.071908966,-0.03235075,0.0038304252,0.015985437,-0.063081,-0.025967065,-0.00011169432,0.03202686,0.02222818,0.021580538,0.06200021,0.056058697,-0.012442548,0.041037224,-0.038264677,0.061620552,0.017108254,0.063912585,-0.018527526,0.03593892,0.06609965,0.05634429,-0.00954517,0.05596861,-0.050551932,-0.043135222,-0.0047234236,-0.04651929,-0.013701045,-0.015487388,-0.036559653,-0.23505731,0.025799984,0.058019146,0.049600147,-0.0149137555,-0.02930647,0.018894762,0.024304276,-0.06986926,0.046896547,0.028301945,0.004159479,0.010240413,-0.0754417,-0.018677292,-0.05084431,0.05911722,-0.05495988,-0.0104590235,0.031092959,0.081136234,0.057686344,0.1618158,0.0025421474,0.060484033,0.034014214,-0.032046318,-0.004300472,-0.012397296,-0.022816878,0.038444635,-0.029992845,0.064407475,-0.038746286,0.039542396,0.021143803,-0.025873534,0.07393825,-0.06332708,-0.06104439,-0.09006894,0.04728321,-0.039618637,-0.029842021,0.067537606,-0.03429696,-0.0023412402,-0.028394742,-0.0136090135,-0.04616168,-0.025908599,-0.05382041,-0.018555326,-0.02151582,-0.008344697,0.009704288,-0.049220063,-0.0075706006,0.03957218,-0.02696479,-0.06906658,0.008207997,0.039097473,-0.043224357,0.028512133], alpha: 0.3, distance_threshold: 0.15)"
        }
    ]
}

Working

{
    "searches": [
        {
            "collection": "Mantis",
            "exclude_fields": "",
            "filter_by": "type:=chunk  \u0026\u0026 labeling.count :\u003e 0 \u0026\u0026 labels: [\"gold\",\"Gold\",\"Precious Metals\",\"hard assets\",\"Metals\",\"Commodities\",\"Metalicity\",\"commodity\",\"Industrial Metals\",\"Investors wanting hard assets\",\"Raw materials\",\"Rare earth elements\",\"Golden Metal Resources\",\"Aurum Resources\",\"Materials\",\"Commodity\",\"Financial markets\",\"financial markets\",\"financial\",\"Rare Earth Elements\",\"finance\",\"Consumer Goods\",\"The prospect of higher-for-longer U.S. rates took some shine off the yellow metal\",\"Energy commodity\",\"Commodities market\",\"Financials\",\"Commodity prices\",\"Precious Metals Market\",\"Commodity market\",\"Financial\",\"commodity prices\",\"Commodity Prices\",\"financial market\",\"Commodity Market\",\"gold equivalent ounces\",\"Luxury Goods\",\"Commodity Trading\",\"Markets\",\"Commodities Trading\",\"Financial Markets\",\"Stocks\",\"Economy\",\"economy\",\"Metals market\",\"Gold Reserve\",\"GoldMining\",\"Gold prices\",\"Equities\",\"Gold Mining\",\"Resources\",\"Currency\",\"Finance\",\"Global financial markets\",\"Currency markets\",\"Sichuan Rongda Gold\",\"Wing Fung Precious Metals\",\"Spanish Mountain Gold\",\"Investing\",\"stock market\",\"Financial Market\",\"Economic\",\"Investment\",\"Currency market\",\"Gold mining\",\"Silver\",\"market\",\"Financial services\",\"Mining\",\"Mining Exploration\",\"The stock market is currently trading at a certain level\",\"Industrials\",\"Banking\",\"Financial sector\",\"Before July\",\"Aurumin\",\"Lundin Gold\",\"financial services\",\"5.48 grams per tonne\",\"Golden Energy and Resources\",\"Palladium\",\"E79 Gold Mines\",\"Geology\",\"Cryptocurrency\",\"Zodiac Gold\",\"Investments\",\"Energy\",\"Harmony Gold\",\"Gold dipped 0.25% to $2,372.28 an ounce\",\"Investors still want hard assets and Lewis says he doesn't see this changing in the short-term.\",\"China Nonferrous Gold\",\"SPDR Gold Shares\",\"mining\",\"metal prices\",\"Stock market\",\"Financial Industry\",\"Price Movement\"] \u0026\u0026 labeling.strategy :!= undefined",
            "q": "gold",
            "query_by": "labels, metadata.title, text",
            "query_by_weights": "10, 3, 5",
            "vector_query": "embedding:([-0.032667983,0.0039473767,0.005812002,0.04523945,-0.017691698,-0.053429432,0.042401485,0.041330967,-0.000029027671,0.009384659,0.025088683,-0.022720717,0.020883393,0.03850513,0.08746865,0.058399133,0.035951823,-0.038359668,-0.15884201,0.084598325,0.047194865,-0.057555784,-0.07196709,-0.086945824,0.008614092,0.021483444,0.015626272,-0.034421194,-0.03548226,-0.109142885,-0.032563172,0.007977602,0.03524069,0.015495696,0.008870208,-0.009546201,-0.012514912,0.025638081,-0.058277216,0.010343512,0.04379806,-0.00034003714,-0.068421915,0.0150450645,0.02343076,0.011689481,0.014109681,-0.010791189,0.013985279,-0.02080013,-0.030339437,0.025625715,0.0024396158,0.052652556,0.058004726,0.049715724,-0.0087079415,0.014394205,0.007854934,0.010127793,0.023935692,0.039525602,-0.15001552,0.050422587,0.010919137,0.02586476,0.0018362217,-0.0033862074,-0.049125146,0.077616565,0.07222657,0.014562906,-0.017269742,0.0601641,0.007429748,-0.0056630983,0.021926256,-0.029780675,0.054912437,0.0063516586,-0.07854355,-0.013342344,-0.064957745,0.018431142,-0.0128257135,-0.06773294,0.011004469,0.021922225,0.056856647,0.016196834,0.024453003,-0.048909172,-0.0070780385,-0.010447104,-0.04354541,-0.027985368,0.013559723,-0.018492686,0.003382786,0.15977976,0.03216482,0.028211659,0.027048795,-0.060040202,0.004624014,0.02439269,-0.02946296,-0.0187307,-0.024048716,-0.006922771,0.040415805,-0.02534655,0.10939681,-0.07549922,-0.026515221,0.05527791,0.024130782,0.00838552,0.0010583013,-0.0011188317,-0.05551308,-0.02542888,0.0025157118,-0.043395597,0.04095863,-0.044930782,0.05189125,0.081526294,-0.06696412,0.09490119,0.04816166,-0.094185375,-0.08406544,-0.02039201,0.0030506682,0.003919931,0.01504405,-0.0249369,0.07679988,0.04635927,-0.090303525,-0.11673996,-0.022063518,-0.07246459,0.0034546363,0.06749547,-0.04145805,-0.031169917,-0.059089318,-0.07506823,-0.056012195,0.0042568846,0.041262504,0.022970384,-0.029883662,0.041901477,0.08016807,0.048634626,-0.057715677,-0.020264108,0.065392464,0.019997764,0.0105482815,0.104196265,0.0255159,-0.107133456,-0.08207006,-0.039118852,-0.025207996,-0.039198443,0.043615885,0.09395943,-0.09045545,0.03103667,0.10145533,-0.044690978,0.004590788,0.032001376,-0.01794705,0.02426285,-0.010811691,-0.0033280079,0.010785056,0.07732925,-0.031716455,-0.089458,-0.00735471,0.03921279,0.054529972,-0.04367007,0.05383027,-0.0013836556,-0.041233648,0.04319662,-0.04512032,-0.023969475,0.004822958,-0.0016430175,-0.03286865,-0.02525829,0.06862477,-0.03217821,-0.009196379,0.04908565,0.031021578,0.027052633,-0.03570627,0.02792165,-0.0025508278,0.023709562,0.008722117,0.02160538,-0.0015203725,0.016102342,-0.020720106,-0.10137227,-0.0001025196,0.00069947774,-0.03027042,0.019991303,0.0128058,-0.056802966,-0.042539794,-0.26045668,0.021828528,-0.011513137,-0.026258873,0.0059395838,0.02361498,0.023611123,-0.015242678,0.09454663,0.09794106,0.04400122,0.012998303,-0.022556363,0.016688332,0.029031899,0.061771896,0.03214569,-0.050796553,0.032054406,0.004151947,-0.008297203,0.003868991,-0.0029843661,-0.08949367,0.041237622,0.035347622,0.20319663,0.09467109,-0.10564916,-0.067829,0.00792331,-0.0285371,-0.06758674,-0.07445657,0.009135262,0.0051551145,0.022373397,0.084889196,-0.05802085,0.015481831,-0.01030594,0.01948649,-0.054303195,0.019580485,0.03654844,-0.00401584,0.04929166,-0.03504597,0.002041342,0.10406345,-0.0028440384,-0.0074305264,0.082981504,0.03256745,-0.010653614,-0.038280837,-0.060251635,-0.01584224,-0.02542106,0.03576775,-0.0022685593,-0.024608321,0.0011773182,0.039372332,0.041638453,-0.071908966,-0.03235075,0.0038304252,0.015985437,-0.063081,-0.025967065,-0.00011169432,0.03202686,0.02222818,0.021580538,0.06200021,0.056058697,-0.012442548,0.041037224,-0.038264677,0.061620552,0.017108254,0.063912585,-0.018527526,0.03593892,0.06609965,0.05634429,-0.00954517,0.05596861,-0.050551932,-0.043135222,-0.0047234236,-0.04651929,-0.013701045,-0.015487388,-0.036559653,-0.23505731,0.025799984,0.058019146,0.049600147,-0.0149137555,-0.02930647,0.018894762,0.024304276,-0.06986926,0.046896547,0.028301945,0.004159479,0.010240413,-0.0754417,-0.018677292,-0.05084431,0.05911722,-0.05495988,-0.0104590235,0.031092959,0.081136234,0.057686344,0.1618158,0.0025421474,0.060484033,0.034014214,-0.032046318,-0.004300472,-0.012397296,-0.022816878,0.038444635,-0.029992845,0.064407475,-0.038746286,0.039542396,0.021143803,-0.025873534,0.07393825,-0.06332708,-0.06104439,-0.09006894,0.04728321,-0.039618637,-0.029842021,0.067537606,-0.03429696,-0.0023412402,-0.028394742,-0.0136090135,-0.04616168,-0.025908599,-0.05382041,-0.018555326,-0.02151582,-0.008344697,0.009704288,-0.049220063,-0.0075706006,0.03957218,-0.02696479,-0.06906658,0.008207997,0.039097473,-0.043224357,0.028512133], alpha: 0.3, distance_threshold: 0.15)"
        }
    ]
}

Expected Behavior

image

Actual Behavior

image

The following label (\"SPDR Gold Shares (GLD)\") is breaking the filter parser.

Metadata

Typesense Version: 0.25.2

OS: Ubuntu 22 LTS

@IonCimpoiesu IonCimpoiesu changed the title BALANCED parenthesis will trigger "Could not parse the filter query. BALANCED parenthesis filter query will trigger "Could not parse the filter query. Jun 1, 2024
@IonCimpoiesu IonCimpoiesu changed the title BALANCED parenthesis filter query will trigger "Could not parse the filter query. BALANCED parentheses filter query will trigger "Could not parse the filter query. Jun 1, 2024
@kishorenc
Copy link
Member

You can wrap the filter value with backticks:

"filter_by": "field_name: `some (value)`"

@IonCimpoiesu
Copy link
Author

Thanks @kishorenc for your feedback. After conducting some Google research with the keywords [wrap, backticks], I found a note in the New Features section for v0.21.0.

Further searches using the Typesense search bar revealed that this New Features note is the only reference on how to use backticks for handling edge cases with dirty data.

To assist other users encountering similar issues, may I suggest adding a detailed example in the API Reference? This would enhance the documentation and provide clear guidance on using backticks in such scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants