Skip to main content
 
 
 
IN THIS SECTION
3 posts
mike
Last seen: 10/17/2019 - 10:04
Joined: 11/14/2017 - 14:22
Searching with _contains

I'm trying to query the API to do partial text searches and thought  "_contains" would work but i must be mis-understadning.

My question is why doesn't _contains work as i'm expecting it to?

Examples below

http://www.patentsview.org/api/patents/query?q={"_contains":{"patent_abstract":"energy"}}

http://www.patentsview.org/api/patents/query?q={"_contains":{"govint_raw_statement":"energy"}}

RESULTS : X-Status-Reason: Invalid field type 'fulltext' or operator '_contains' found for 'patent_abstract'

 

I switched to using "_text_any" and it works

http://www.patentsview.org/api/patents/query?q={"_text_any":{"patent_abstract":"energy"}}

http://www.patentsview.org/api/patents/query?q={"_text_any":{"govint_raw_statement":"energy"}}

 

Russ
Last seen: 10/06/2021 - 12:24
Joined: 11/14/2017 - 22:15
SEARCHING WITH _CONTAINS

Mike,

The language page says that "_contains" is for string fields while "_text_any" is for full text fields.  The patents endpoint page says that both of your fields are of type full text.  I had the opposite problem until I realized what was going on.  I was trying to do a _text_any on location_city which is a string field.  Once I figured out what the problem was the X-Status-Reason header made way more sense.   For some real fun try http://www.patentsview.org/api/locations/query?q={"_contains":{"location_city":" Airport"}}

Russ

PVTeam
Role: moderator
Last seen: 10/06/2021 - 11:29
Joined: 10/17/2017 - 10:47
SEARCHING WITH _CONTAINS

You are correct - the _contains operator only works on fields that are specified as strings, not full text. 

~PatentsView Team