A pesquisa em Ghini¶
Pesquisa permite-lhe visualizar, navegar e criar relatórios a partir de seus dados. Você pode executar pesquisas digitando as consultas na entrada principal da busca ou usando o construtor de consultas para criar as consultas para você. Os resultados de pesquisas Ghini estão listados na janela principal.
Estratégias de Pesquisa¶
Ghini oferece quatro estratégias de busca distintas:
- por valor — em todos os domínios;
- por expressão — em alguns campos implícitos num domínio explícito;
- por consulta — num domínio;
- por nome binomial — pesquisa somente o domínio de espécies.
Todas as estratégias de pesquisa — com a notável excepção da pesquisa nome binomial — não diferenciam maiusculas de minúsculas.
Pesquisa por Valor¶
Pesquisar por valor é a maneira mais simples para pesquisar. Entra uma ou mais cadeias de caracteres e ver o que corresponde. O resultado inclui objetos de qualquer tipo (domínio) onde um ou mais dos seus campos contêm uma, ou mais das cadeias de pesquisa.
Você não especifica o domínio de pesquisa, todos estão incluídos, nem você indica quais dos campos você deseja corresponder, isso está implícito no domínio de pesquisa.
A tabela a seguir ajuda a entender os resultados e orienta a formulação de suas pesquisas.
Visão geral dos domínios de pesquisa | ||
---|---|---|
nome e atalhos | campo | tipo de resultado |
family, fam | epithet (family) | Family |
genus, gen | epithet (genus) | Genus |
species, sp | epithet (sp) × | Species |
vernacular, common, vern | nome | Species |
geography, geo | nome | Geography |
accession, acc | code | Accession |
planting, plant | code × | Plant |
location, loc | code, name | Location |
contact, person, org, source | nome | Contact |
collection, col, coll | locale | Collection |
tag, tags | nome | Tag |
Exemplos de busca pelo valor seria: Maxillaria, Acanth, 2008.1234, 2003.2.1, Índica.
A menos que use explicitamente aspas, os espaços separam pesquisar cadeia de caracteres. Por exemplo, se pesquisar por bloco 10
, então Ghini irá procurar as secuências bloco
e 10
e retornar todos os resultados que correspondam a qualquer destas secuências. Se deseja pesquisar para bloco 10
como uma sequência inteira, em seguida, deve citar a sequência de caracteres como 'bloco 10'
.
× Chaves primárias compostas
Um epíteto de espécies significa pouco, sem o correspondente gênero, da mesma forma, um código planta é exclusivo apenas dentro da accesão ao qual ele pertence. Na terminologia de teoria de banco de dados, epíteto e o código não são suficientes para formar uma chave primária pela, respectivamente, espécie e planta. Nestes domínios, precisamos de uma chave primária composta.
Pesquisar por valor permite que você procure por plantas pelo seu código de plantação completo, que inclui o código de accesão. Tomados em conjunto, o código de accesão e código de plantio fornecem uma chave primária composta para plantas. Para espécies, nós introduzimos a busca binomial, descrita abaixo.
Pesquisa por Expressão¶
Searching with expression gives you a little more control over what you are searching for. You narrow the search down to a specific domain, the software defines which fields to search within the domain you specified.
Uma expressão é construído como <domain> <operador> <valor>
. Por exemplo, a pesquisa: gen=Maxillaria
vai retornar todos os gêneros que correspondem ao nome Maxillaria. Neste caso, o domínio é gen
, o operador =
e o valor é Maxillaria
.
A tabela acima, de visão geral de domínio de pesquisa, diz os nomes dos domínios de pesquisa, e, por domínio de busca, quais campos são pesquisados.
The search string loc like block%
would return all the Locations for
which name or code start with «block». In this case the domain is loc
(a shorthand for location
), the operator is like
(this comes from
SQL and allows for «fuzzy» searching), the value is block%
, the
implicitly matched fields are name
and code
. The percent sign is
used as a wild card so if you search for block%
then it searches for all
values that start with block
. If you search for %10
it searches for all
values that end in 10
. The string %ck%10
would search for all value
that contain ck
and end in 10
.
Quando uma consulta leva uma eternidade para completar
Você dá uma consulta, isso demora algum tempo para calcular, e o resultado contém exageradamente muitas entradas. Isso acontece quando você pretende usar uma estratégia, mas suas cordas não formam uma expressão válida. Neste caso, Ghini reverterá para busca por valor. Por exemplo, a sequência gen lik maxillaria
irá procurar a cadeia de caracteres gen
, lik
e maxillaria
, retornando tudo o que corresponde a pelo menos um dos três critérios.
Pesquisar binomial¶
You can also perform a search in the database if you know the species, just by placing a few initial letters of genus and species epithets in the search engine, correctly capitalized, i.e.: Genus epithet with one leading capital letter, Species epithet all lowercase.
Desta forma você pode realizar a pesquisa So ha
.
Estas seriam as iniciais de Solanum hayesii, ou do Solanum havanense.
Pesquisar binomial vem para compensar a utilidade limitada da pesquisa acima pela expressão ao tentar procurar uma espécie.
It is the correct capitalization Xxxx xxxx that informs the software of your intention to perform a binomial search. The software’s second guess will be a search by value, which will possibly result in far more matches than you had expected.
O pedido semelhante so ha
retornará, em uma instalação nova, mais de 3000 objetos, começando na Família «Acalyp(ha)ceae», terminando em a Geografia «Western (So)uth América».
Procura por Consulta¶
Queries allow the most control over searching. With queries you can search
across relations, specific columns, combine search criteria using boolean
operators like and
, or
, not
(and their shorthands &&
,
||
, !
), enclose them in parentheses, and more.
Please contact the authors if you want more information, or if you volunteer to document this more thoroughly. In the meanwhile you may start familiarizing yourself with the core structure of Ghini’s database.
A few examples:
plantings of family Fabaceae in location Block 10:
plant WHERE accession.species.genus.family.epithet=Fabaceae AND location.description="Block 10"
locations that contain no plants:
location WHERE plants = Empty
accessions associated to a species of known binomial name (e.g.: Mangifera indica):
accession WHERE species.genus.epithet=Mangifera AND species.epithet=indica
accessions we propagated in the year 2016:
accession WHERE plants.propagations._created BETWEEN |datetime|2016,1,1| AND |datetime|2017,1,1|
accessions we modified in the last three days:
accession WHERE _last_updated>|datetime|-3|
Searching with queries requires some knowledge of a little syntax and an idea of the extensive Ghini database table structure. Both you acquire with practice, and with the help of the Query Builder.
The Query Builder¶
Ghini offers a Query Builder, that helps you build complex search queries through a point and click interface. To open the Query Builder click the icon to the left of the search entry or select from the menu.
A window will show up, which will lead you through all steps necessary to construct a correct query that is understood by Ghini’s Query Search Strategy.
First of all you indicate the search domain, this will allow the Query
Builder complete its graphical user interface, then you add as many logical
clauses as you need, connecting them with a and
or or
binary
operator.
Each clause is formed of three parts: a property that can be reached from the starting search domain, a comparison operator that you select from the drop-down list, a value that you can either type or select from the list of valid values for the field.
Add as many search properties as you need, by clicking on the plus sign. Select and/or next to the property name to choose how the clauses will be combined in the search query.
When you are done building your query click OK to perform the search.
At this point the Query Builder writes the query in the search entry, and
executes it. You may now edit the string as if you had typed it
yourself. Notice how the left hand side values are interpreted by the query
builder and enclosed in single quotes if recognized as strings, left alone
if they look like numbers or the two reserved words None
and
Empty
. You may edit the query and insert quotes if you need them, eg if
you need to literally look for the string Empty
.
None
is the value of an empty field. It is not the same as the zero
lenght string ''
nor the numeric 0
nor the boolean False
nor the
set Empty
, it indicates that the field has no value at all.
Empty
is the empty set. Being it a set, it can be matched against sets
(eg: plants of an accession, or accessions of a species), not against
elements (eg: quantity of a plant or description of a location). However,
the Query Builder does not let you choose a left hand side value stopping at
a set, it expects you to select a field. Choose just any field: at the
moment of producing the query, when the Query Builder meets a clause with
right hand side value the literal string Empty
, it will drop the field
name and let you compare the set on the left with Empty
on the right.
We have no literals False
and True
. These are typed values, and the
Query Builder does not know how to produce them. Instead of False
type
0
, and instead of True
type 1
.
Query Grammar¶
For those who don’t fear a bit of formal precision, the following BNF code gives you a rather precise idea of the grammar implemented by the Query Search Strategy. Some grammatical categories are informally defined; any missing ones are left to your fertile imagination; literals are included in single quotes; the grammar is mostly case insensitive, unless otherwise stated:
query ::= domain 'WHERE' expression
domain ::= #( one of our search domains )
expression ::= signed_clause
| signed_clause 'AND' expression
| signed_clause 'OR' expression
;
signed_clause ::= clause
| 'NOT' clause #( not available in Query Builder)
;
clause ::= field_name binop value #( available in Query Builder)
| field_name set_binop value_list
| aggregated binop value
| field_name 'BETWEEN' value 'AND' value
| '(' expression ')'
;
field_name ::= #( path to reach a database field or connected table )
aggregated ::= aggregating_func '(' field_name ')'
aggregating_func ::= 'SUM'
| 'MIN'
| 'MAX'
| 'COUNT'
;
value ::= typed_value
| numeric_value
| none_token
| empty_token
| string_value
;
typed_value ::= '|' type_name '|' value_list '|'
numeric_value ::== #( just a number )
none_token ::= 'None' #( case sensitive )
empty_token ::= 'Empty' #( case sensitive )
string_value = quoted_string | unquoted_string
type_name ::= 'datetime' | 'bool' ; #( only ones for the time being )
quoted_string ::= '"' unquoted_string '"'
unquoted_string ::= #( alphanumeric and more )
value_list ::= value ',' value_list
| value
;
binop ::= '='
| '=='
| '!='
| '<>'
| '<'
| '<='
| '>'
| '>='
| 'LIKE'
| 'CONTAINS'
;
set_binop ::= 'IN'
Please be aware that Ghini’s Query language is quite a bit more complex than what the Query Builder can produce: Queries you can build with the Query Builder form a proper subset of the queries recognized by the software:
query ::= domain 'WHERE' expression
domain ::= #( one of our search domains )
expression ::= clause
| clause 'AND' expression
| clause 'OR' expression
;
clause ::= field_name binop value
;
field_name ::= #( path to reach a database field or connected table )
value ::= numeric_value
| string_value
;
numeric_value ::== #( just a number )
string_value = quoted_string | unquoted_string ;
quoted_string ::= '"' unquoted_string '"'
unquoted_string ::= #( alphanumeric and more )
binop ::= '='
| '=='
| '!='
| '<>'
| '<'
| '<='
| '>'
| '>='
| 'LIKE'
| 'CONTAINS'
;