Gravatar for lautaro.bonetto@gmail.com

Question by Lautaro Bonetto, Mar 5, 2016 10:00 AM

Why do I have this "InvalidQueryFunctionSyntax" error?

Hi,
I'm working with Sitecore 8 and Coveo for Sitecore. Coveo has created automatically a collection and source with all my Sitecore items within. I want to use that collection to get the distance using query functions. Unfortunatelly, all the time Coveo is returning a wrong syntax error message. My question is: What am I writing wrong on the URL? I cannot find the mistake.

URL:

http://localhost:8080/rest/search?q=1%20stop%2019&queryFunctions=[{"function":"dist(@flongitude20567,@flatitude20567,30,30)","fieldName":"distance"}]

Coveo API Service response:

{
"totalCount": 1,
"totalCountFiltered": 1,
"duration": 12,
"indexDuration": 10,
"requestDuration": 11,
"searchId": "81a00545-4047-42bd-a9c2-af45f070b2b7",
"exception": {
    "code": "InvalidQueryFunctionSyntax",
    "context": "distance"
},
"termsToHighlight": {
    "1": [],
    "19": [],
    "stop": []
},
"phrasesToHighlight": {},
"queryCorrections": [],
"groupByResults": [],
"results": [
    {
        "title": "1 STOP 19",
        "uri": "sitecore://database/master/ItemId/{A4676D23-4F6C-414D-A817-3FB01864652B}/Language/en/Version/1",
        "printableUri": "localhost/Coveo_master_index - WIN-TEST-xomfl/1 STOP 19",
        "clickUri": "http://xomfl/Cross Brand/Apps/Locator/Entities/1 STOP 19",
        "uniqueId": "-1$0$16851.10607$sitecore://database/master/itemid/{a4676d23-4f6c-414d-a817-3fb01864652b}/language/en/version/1",
        "excerpt": "",
        "firstSentences": null,
        "summary": null,
        "flags": "",
        "hasHtmlVersion": false,
        "hasMobileHtmlVersion": false,
        "score": 9261,
        "percentScore": 97.5251,
        "rankingInfo": null,
        "isTopResult": false,
        "titleHighlights": [
            {
                "length": 1,
                "offset": 0
            },
            {
                "length": 4,
                "offset": 2
            },
            {
                "length": 2,
                "offset": 7
            }
        ],
        "firstSentencesHighlights": [],
        "excerptHighlights": [],
        "printableUriHighlights": [
            {
                "length": 1,
                "offset": 53
            },
            {
                "length": 4,
                "offset": 55
            },
            {
                "length": 2,
                "offset": 60
            }
        ],
        "summaryHighlights": [],
        "parentResult": null,
        "childResults": [],
        "totalNumberOfChildResults": 0,
        "raw": {
            "fz95xgroup20567": "a4676d234f6c414da8173fb01864652b",
            "fempty20567": "0",
            "fz95xtemplatename20567": "Entity",
            "fz95xdatasource20567": "Sitecore",
            "systitle": "1 STOP 19",
            "fdisplayname20567": "1 STOP 19",
            "fz95xz95xisz32xbucket20567": "0",
            "systopparent": "212323855271529825",
            "sysurihash": "AXFx058HXe4b9Wvt",
            "furi20567": "sitecore://master/{A4676D23-4F6C-414D-A817-3FB01864652B}?lang=en&ver=1",
            "sysuri": "localhost/Coveo_master_index - WIN-TEST-xomfl/1 STOP 19",
            "sysprintableuri": "localhost/Coveo_master_index - WIN-TEST-xomfl/1 STOP 19",
            "sysfolders": "00001sitecore://localhost/f90646e4\n00002sitecore://localhost/coveo_master_index - win-test-xomfl/26aafa35",
            "ffullpath20567": "/sitecore/content/Cross Brand/Apps/Locator/Entities/1 STOP 19",
            "fdisplayz32xname20567": "1 STOP #19",
            "frevision20567": "b4c72731-6d61-42eb-bcb2-16e6b50d7375",
            "fcreated20567": 1455110571000,
            "fisfullyqualified20567": "1",
            "fhaslayout20567": "0",
            "fz95xlatestversion20567": "1",
            "fz95xz95xsmallupdateddate20567": 1457076132000,
            "flocationz32xname20567": "1 STOP 19",
            "fismediaitem20567": "0",
            "fparsedcreatedby20567": "sitecoreadmin",
            "fhideversion20567": "0",
            "ftemplateid20567": "c1787be9-1189-41cf-8518-dc2d13578be1",
            "sysindexeddate": 1457058274000,
            "fkey20567": "1 stop 19",
            "fz95xid20567": "a4676d234f6c414da8173fb01864652b",
            "falltemplates20567": "c1787be9118941cf8518dc2d13578be1;1930bbeb7805471aa3be4858ac7cf696;75c4f2eca3e04a878f43a3f73cd28730;23d1fc34999541e2bcd03239431948cb",
            "fz95xparent20567": "1e09018c28e04ab88cf4ddaef1ae5cea",
            "finvalid20567": "0",
            "freadonly20567": "0",
            "fz95xtemplate20567": "c1787be9118941cf8518dc2d13578be1",
            "fz95xpath20567": "11111111111111111111111111111111;0de95ae441ab4d019eb067441b7c2450;43970a3ab10e44b28726a5334a9ab0d9;8a7e2f488658456b9d59052f98b4f36c;98790a2728fe4472bc0b9577d9b72663;1e09018c28e04ab88cf4ddaef1ae5cea;a4676d234f6c414da8173fb01864652b",
            "fpath20567": "/sitecore/content/Cross Brand/Apps/Locator/Entities/1 STOP 19",
            "fownerdatabase20567": "master",
            "fz95xfullpath20567": "/sitecore/content/cross brand/apps/locator/entities/1 stop 19",
            "furllink20567": "/en/Cross Brand/Apps/Locator/Entities/1 STOP 19",
            "flocationz32xid20567": "320378",
            "fid20567": "a4676d234f6c414da8173fb01864652b",
            "fupdatedby20567": "sitecore\\admin",
            "fappearancethumbnail20567": "/sitecore/client/images/document16x16.gif",
            "fhaschildren20567": "0",
            "fisbucketz95xtez120xt20567": "0",
            "fstorez32xamenities20567": "862b8bb6b076436b80ccade7f9c25e85",
            "fappearanceicon20567": "Applications/32x32/form_blue.png",
            "syssite": "database",
            "sysconnectortype": "QueueCrawler",
            "fbrowseonly20567": "0",
            "fisvirtual20567": "0",
            "fisitemclone20567": "0",
            "fmediapath20567": "/sitecore/content/Cross Brand/Apps/Locator/entities/1 STOP 19",
            "fz95xz95xhidden20567": "0",
            "fistemplate20567": "0",
            "fhidden20567": "0",
            "flatitude20567": 31,
            "flanguage20567": "en",
            "fz95xdatabase20567": "master",
            "fculture20567": "en",
            "fisez120xternal20567": "0",
            "fpostalz32xcode20567": "48458",
            "sysdocumenttype": "Document",
            "fforcemodified20567": "0",
            "fdatauri20567": "sitecore://{A4676D23-4F6C-414D-A817-3FB01864652B}?lang=en&ver=1",
            "fabsolutepath20567": "/Cross Brand/Apps/Locator/Entities/1 STOP 19",
            "fversion20567": "1",
            "fpublishdate20567": -17955889200000,
            "funpublishdate20567": 253370782799000,
            "furlstring20567": "?db=master&id=%7BA4676D23-4F6C-414D-A817-3FB01864652B%7D&la=en&vs=1",
            "syssource": "Coveo_master_index - WIN-TEST-xomfl",
            "syssize": 27879,
            "sysdate": 1457058132000,
            "fz95xupdated20567": 1457076132000,
            "fparsedlanguage20567": "english",
            "fismasterpart20567": "0",
            "fz95xz95xupdated20567": 1457076132000,
            "flanguages20567": "en;da;de-DE;el-GR;es-ES;fi-FI;fr-FR;it-CH;ja-JP;ko-KR;nb-NO;nl-BE;pl-PL;pt-PT;ro-RO;ru-RU;sv-FI;th-TH;tr-TR;zh-SG;es-CO;fr-CA",
            "fz95xdisplayname20567": "1 STOP 19",
            "fdatasource20567": "Sitecore",
            "fupdated20567": 1457076132000,
            "flongitude20567": 31,
            "systopparentid": 212323855271529820,
            "fz95xz95xbucketable20567": "0",
            "fz95xeditor20567": "sitecore\\admin",
            "fbranchid20567": "00000000000000000000000000000000",
            "fappearancedisplayname20567": "1 STOP 19",
            "fsite20567": "coveoanalytics;coveorest;login;admin;service;website;scheduler;system;publisher",
            "fname20567": "1 STOP 19",
            "fparentid20567": "1e09018c-28e0-4ab8-8cf4-ddaef1ae5cea",
            "ftemporary20567": "0",
            "fz95xname20567": "1 STOP 19",
            "fboostingvalue20567": 0,
            "fz95xisclone20567": "0",
            "fvalidto20567": 253370782799000,
            "fz95xz95xsmallcreateddate20567": 1455110571000,
            "flock20567": "0",
            "fz95xversion20567": "1",
            "syssourcetype": "Queue",
            "fz95xlanguage20567": "en",
            "fdatabasename20567": "master",
            "findez120xableitemuniqueid20567": "sitecore://master/{A4676D23-4F6C-414D-A817-3FB01864652B}?lang=en&ver=1",
            "ftemplatename20567": "Entity",
            "sysclickableuri": "http://xomfl/Cross Brand/Apps/Locator/Entities/1 STOP 19",
            "fappearancesortorder20567": "100",
            "sysfiletype": "sitecoreitem",
            "fcontentpath20567": "/Cross Brand/Apps/Locator/Entities/1 STOP 19",
            "fneverpublish20567": "0",
            "fdefaulturi20567": "sitecore://master/{A4676D23-4F6C-414D-A817-3FB01864652B}?lang=en&ver=1",
            "fisclone20567": "0",
            "fz95xuniqueid20567": "sitecore://master/{a4676d23-4f6c-414d-a817-3fb01864652b}?lang=en&ver=1",
            "ftemplatedatabase20567": "master",
            "fiscontentitem20567": "1",
            "sysisemptydocument": "true",
            "sysrowid": 28285,
            "syscollection": "Sitecore Search Provider",
            "fparentpath20567": "/sitecore/content/Cross Brand/Apps/Locator/Entities",
            "findez120xableitemid20567": "a4676d234f6c414da8173fb01864652b"
        },
        "Title": "1 STOP 19",
        "Uri": "sitecore://database/master/ItemId/{A4676D23-4F6C-414D-A817-3FB01864652B}/Language/en/Version/1",
        "PrintableUri": "localhost/Coveo_master_index - WIN-TEST-xomfl/1 STOP 19",
        "ClickUri": "http://xomfl/Cross Brand/Apps/Locator/Entities/1 STOP 19",
        "UniqueId": "-1$0$16851.10607$sitecore://database/master/itemid/{a4676d23-4f6c-414d-a817-3fb01864652b}/language/en/version/1",
        "Excerpt": "",
        "FirstSentences": null
    }
]

}

Thanks a lot.
Lautaro

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Mar 5, 2016 12:48 PM

I don't have the documentation handy but did you try @distance for your field name?

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Mar 7, 2016 10:28 AM

Hi Lautaro,

I think your problem is a known issue with releases of the Coveo Search API older than 8.0.301 (December 2014 release for Coveo for Sitecore January 2015). A bug was present in the query functions where the arguments were inverted before being transferred to the Coveo Enterprise Search index leading to the error message you described (see December 2014 release notes).

The proper solution would be to upgrade your Coveo Search API to the 8.0.301 release or newer. Since with Coveo for Sitecore all the software should have the same monthly version, you would have to upgrade Coveo Enterprise Search and Coveo for Sitecore as well.

A workaround would be to define your query function in the advanced query expression (aq) instead of the queryFunctions array like this:

http://localhost:8080/rest/search?q=1%20stop%2019&aq=$qf(function:'dist(@flongitude20567,@flatitude20567,30,30)',fieldName:@distance)

Let me know if the cause of the problem is your Coveo Search API version and if the solution/workaround worked.

Jeff

Gravatar for lautaro.bonetto@gmail.com

Comment by Lautaro Bonetto, Mar 7, 2016 10:38 AM

Perfect. That URL works perfect. I can get the distance now.
I'll recommend you to update the Coveo's documentation to show this other way to get the distance clearly, and avoid frustrations.

Ask a question