query script AND, OR, NOT

CorText Manager Q&A forumCategory: Data processingquery script AND, OR, NOT
hugues asked 6 years ago

Hello,
I’d like to know how to use the query script by combining the different operators AND, OR, NOT.

Do you have any documentation on this?
Thank you.

Hugues
 

3 Answers
Lionel Staff answered 6 years ago

Hi Hugues,
Yest, the documentation of the Query Script is published here: https://docs.cortext.net/query-corpus/
You have to select which variable you want to Query with the “target table name” parameter (e.g. ISIC1Country to query the country field)
And to precise what is your SQL query in the “condition” parameter (e.g. data = ‘france’ OR data = ‘usa’ OR data=’italie’ to select documents that have a least one of this three countries mentioned in their country list).
I hope it helps.
Lionel

hugues answered 6 years ago

Thanks for your help Lionel.

A complementary question: in the “condition” field, is it possible to combine several booleans in the same query? For example:
– data = (‘france’ OR data = ‘usa’ OR data = ‘italy’) NOT (germany)


Thanks again.

Hugues

Lionel Staff answered 6 years ago

Yes, but not like this! You must follow the SQLite Boolean rules.
The best way is to write in a human way what you want in your sub-selection, and to translate it in SQLite syntax.
For example, if you have a list of countries:

  • data IN (‘france’, ‘usa’)
  • data = ‘france’ OR  data=’usa’

will produce the same results. And:

  • data NOT IN (‘france’, ‘usa’)
  • data <> ‘france’ AND data <> ‘usa’

are also equivalent.
You need to look the SQLite Boolean rules. Pay attention that you could have multiple value (multiple distinct country names) for one document 🙂
L