<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Dear Andrius,</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Thank you so much for your quick response.</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
We are looking forward to have exact matches in COD. Thank you so much!</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Regarding "HAS CONTAINS", this does not seem to work with the Lark validator we have. In our system, we use a query validator to check for valid optimade filters. This is done by the Lark language interpreter which the optimade library uses. It gives an error
when this combination is used. Here is an example:</div>
<blockquote style="margin-left: 0.8ex; padding-left: 1ex; border-left: 3px solid rgb(200, 200, 200);">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Unable to parse filter ( _psdi_authors HAS CONTAINS " Day " ). Lark traceback: </div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
No terminal matches 'C' in the current parser context, at line 1 col 21</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
( _psdi_authors HAS CONTAINS " Day " )</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
^</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Expected one of: </div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* SIGNED_INT</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* OPERATOR</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* FALSE</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* SIGNED_FLOAT</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* ESCAPED_STRING</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* TRUE</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* ALL</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* IDENTIFIER</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* ANY</div>
<div style="font-family: "Lucida Console", Monaco, monospace; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
* ONLY</div>
</blockquote>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
May I ask you, whenever you get around to it, to double check with Optimade spec if this is allowed please? Unless it is a legal Optimade query, we will not be able to use it. Moreover, Matthew Evans has done a private API for us and CONTAINS operator in the
way I showed above is how we use it (e.g., author.names CONTAINS "..."). I might be wrong, but may be the "authors" is the list here and "authors.name" is actually a string? I think Mattew Evans is the best person to answer that, I haven't looked to the Optimade
spec for a while now 🙂</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Once again, thank you for your quick response. I'll keep on checking to see if exact matches are available for us to use
<span id="🙂">🙂</span></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Best,</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Mehmet.</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Andrius Merkys <andrius.merkys@gmail.com><br>
<b>Sent:</b> 17 November 2025 14:21<br>
<b>To:</b> Giritli, Mehmet (STFC,RAL,SC) <mehmet.giritli@stfc.ac.uk><br>
<b>Cc:</b> cod-bugs@ibt.lt <cod-bugs@ibt.lt><br>
<b>Subject:</b> Re: [Cod-bugs] Authors matching in Optimade API</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Dear Mehmet,<br>
<br>
On 2025-11-17 16:08, Mehmet Giritli - STFC UKRI wrote:<br>
> I am trying to use Optimade API to search using author names. But I <br>
> noticed a behaviour which is a bit unexpected.<br>
> <br>
> Consider this query:<br>
> <br>
> authors.name HAS "A. Day"<br>
> <br>
> The spec for HAS operator says that this should only match if there is <br>
> an exact match, i.e., there is an author which is equal to "A. Day", in <br>
> the record.<br>
> <br>
> Here is COD's output:<br>
> <a href="https://www.crystallography.net/cod/optimade/references?filter=authors.name%20HAS%20%22A.%20Day%22">
https://www.crystallography.net/cod/optimade/references?filter=authors.name%20HAS%20%22A.%20Day%22</a> <<a href="https://www.crystallography.net/cod/optimade/references?filter=authors.name%20HAS%20%22A.%20Day%22">https://www.crystallography.net/cod/optimade/references?filter=authors.name%20HAS%20%22A.%20Day%22</a>><br>
> <br>
> The single record above includes an author "A. Dayalan". However, I <br>
> think this should not be the case. It seems like "HAS" implementation <br>
> behaves like what I would expect from "CONTAINS" implementation. But, <br>
> this means that there is no way to get only the records which contain <br>
> values we are explicit about.<br>
<br>
You are right, here the COD's OPTIMADE implementation deviates slightly <br>
from the OPTIMADE specification. Given our backend, implementing support <br>
for such queries to the letter has proven to be too complicated, thus at <br>
the moment we have this deviation. I think it would be nice to at least <br>
emit a warning from our side.<br>
<br>
> That said, I also noticed that CONTAINS is not implemented for <br>
> author.names at the moment:<br>
> <br>
> <a href="https://www.crystallography.net/cod/optimade/references?filter=authors.name%20CONTAINS%20%22A.%20Day%22">
https://www.crystallography.net/cod/optimade/references?filter=authors.name%20CONTAINS%20%22A.%20Day%22</a> <<a href="https://www.crystallography.net/cod/optimade/references?filter=authors.name%20CONTAINS%20%22A.%20Day%22">https://www.crystallography.net/cod/optimade/references?filter=authors.name%20CONTAINS%20%22A.%20Day%22</a>><br>
<br>
In this case the filter string should be:<br>
<br>
authors.name HAS CONTAINS "A. Day"<br>
<br>
(Notice the addition of 'HAS'). 'CONTAINS' alone is an operator acting <br>
on strings, not on lists.<br>
<br>
> To sum up my request, do you think it is possible to:<br>
> <br>
> 1.<br>
> Change implementation of "author.names HAS" so that it allows only<br>
> exact matching.<br>
<br>
This should be doable, it just needs additional work from our side.<br>
<br>
> 2.<br>
> Implement "author.names CONTAINS" which is basically the current<br>
> implementation you have for HAS.<br>
<br>
As explained, 'author.names CONTAINS' should be changed to 'author.names <br>
HAS CONTAINS', as 'author.names CONTAINS' should not work on any <br>
OPTIMADE implementation.<br>
<br>
> I hope it made sense. Please let me know if there is a way to overcome <br>
> this situation currently (e.g., to exact match an author) in your API.<br>
<br>
Thanks for contacting us regarding this issue.<br>
<br>
Best wishes,<br>
Andrius<br>
<br>
-- <br>
Andrius Merkys<br>
Vilnius University Institute of Biotechnology, SaulÄ—tekio al. 7<br>
LT-10257 Vilnius, Lithuania<br>
</div>
</span></font></div>
<br />--
<br />This message has been scanned for viruses and
<br />dangerous content by
<a href="http://www.mailscanner.info/"><b>MailScanner</b></a>, and is
<br />believed to be clean.
</body>
</html>