What does the map for SynonymType.entities look like? - google-assistant-sdk

I can't seem to figure out how to actually create a synonym for Google Assistant to map labels and label to label when answering a query.
Here's my type file:
synonym:
# matchType: FUZZY_MATCH
acceptUnknownValues: false
entities:
label:
Unfortunately, the value of intent.params.{fieldName}.resolved continues to map to labels (plural) when spoken as a plural phrase. The documentation doesn't specify what the map for entities should look like.
Documentation links:
https://developers.google.com/assistant/actionssdk/reference/rest/Shared.Types/Type
https://developers.google.com/assistant/actionssdk/reference/rest/Shared.Types/SynonymType

Based on this example: https://github.com/actions-on-google/actions-builder-facts-about-google-nodejs/blob/master/sdk/custom/types/fact_category.yaml
Google Assistant SDK SynonymType should look like this:
synonym:
entities:
'resolved value':
synonyms:
- 'proposed match 1'
- 'proposed match 2'
- 'proposed match 3'
matchType: EXACT_MATCH

Related

How to pass the whole map as a property when using apoc.load.csv while creating nodes?

I am trying to create nodes by loading a csv file. Since I wanted to exclude some columns I decided to use apoc.load.csv instead of the simpler LOAD CSV command.
I wanted to have all the columns present as corresponding property value for the nodes. However I am not able to figure out how to do it. When the columns are less you can hardcode it, but in my real dataset I have more than 60 columns so I was hoping that there would be a programmatic way to achieve what I want to do.
Demo Dataset you can use data.csv -
name,age,beverage,country_from,fruit
Selma,9,Soda,RU,Apple
Rana,12,Tea,USA,Orange
Selina,19,Cola,CA,Guava
What I have tried so far that doesn't work yet -
CALL apoc.load.csv('data.csv', {header:true, ignore:['beverage'],
mapping:{
age: {type:'int'},
country_from: {name: "country"}
}
})
YIELD map as row
CREATE (e:Entity $row)
CREATE (f:Fruit {name: row.fruit})
CREATE (c:Country {name: row.country_from})
MERGE (e:Entity)-[:EATS]->(f:Fruit)
MERGE (e:Entity)-[:IS_FROM]->(c:Country)
RETURN e,c,f
Expected Output:
The graphdatabase has the Entity nodes with properties name,age,country,fruit
Initially I was using {row} but then I got the error as described here
The old parameter syntax `{param}` is no longer supported. Please use `$param` instead
so I switched to using $row but then I get -
Expected parameter(s): row
I have followed the ideas from the following links -
https://neo4j-contrib.github.io/neo4j-apoc-procedures/3.4/export-import/load-csv/
https://neo4j.com/labs/apoc/4.1/import/load-csv/

How to express multiple property set criteria for node selection using gremlin query

Here is my simplified graph schema,
package:
property:
- name: str (indexed)
- version: str (indexed)
I want to query the version using multiple set of property criteria within single query. I can use within for a list of single property, but how to do it for multiple properties?
Consider I have 10 package nodes, (p1,v1, p2,v2, p3,v3,.. p10,v10)
I want to select only nodes which has (p1 with v1, p8 with v8, p10 with v10)
Is there a way to do with single gremlin query?
Something equivalent to SELECT * from package WHERE (name, version) in ((p1,v1),(p8,v8),(p10,v10)).
It's always best to provide some sample data when asking questions about Gremlin. I assume that this is an approximation of what your model is:
g.addV('package').property('name','gremlin').property('version', '1.0').
addV('package').property('name','gremlin').property('version', '2.0').
addV('package').property('name','gremlin').property('version', '3.0').
addV('package').property('name','blueprints').property('version', '1.0').
addV('package').property('name','blueprints').property('version', '2.0').
addV('package').property('name','rexster').property('version', '1.0').
addV('package').property('name','rexster').property('version', '2.0').iterate()
I don't think that there is a way that you can compare pairs of inputs and expect an index hit. You therefore have to do what you normally do in graphs and choose the index to best narrow your results before you filter in memory. I would assume that in your case this would be the "name" property, therefore grab those first then filter the pairs:
gremlin> g.V().has('package','name', within('gremlin','blueprints')).
......1> elementMap().
......2> where(select('name','version').is(within([name:'gremlin',version:'2.0'], [name:'blueprints',version:'2.0'])))
==>[id:3,label:package,name:gremlin,version:2.0]
==>[id:12,label:package,name:blueprints,version:2.0]
this might not be the most "creative" way of doing that,
but I think that the easiest way would be to use or:
g.V().or(
hasLabel('v1').has('prop', 'p1'),
hasLabel('v8').has('prop', 'p8'),
hasLabel('v10').has('prop', 'p10')
)
example: https://gremlify.com/6s

Use different analyzer depending on node property in Neo4J

I am creating a single database to store nodes with content in several languages.
I have a model like:
(Book {title, summary, text})<-[WRITES {date}]-(Author {name, lang})
I would like to be able to perform full text search on Book's titles and text in several language.
I have tried to simply create several index with different analyzer in a very stupid way:
CALL db.index.fulltext.createNodeIndex("searchEN",["Book"],["title", "summary", "text"], {analyzer: "english")
CALL db.index.fulltext.createNodeIndex("searchFR",["Book"],["title", "summary", "text"], {analyzer: "french")
But when I try to create the index for french I get this error:
neobolt.exceptions.ClientError: There already exists an index NODE:label[0](property[1], property[9], property[11]).
A solution I would like would to limit a search in English to books that are written by an English speaking author without having to create a new node type like EnglishBook. I want to avoid it because other node types of the schema can share connections with books of different language.
For instance I still want to be able to do:
MATCH (p: Publisher)-[r: PUBLISHES]->(b: Book)
RETURN p, r, b

Example of full-text search across multiple fields in Neo4j?

I've seen some simple examples text searching STARTS WITH name such as:
http://www.jexp.de/blog/html/full-text-and-spatial-search-in-neo4j-3.html
https://blog.knoldus.com/2016/12/11/neo4j-with-scala-neo4j-vs-elasticsearch/
But I'm looking for something more along the lines of full-text search across multiple fields: title, content:
https://www.digitalocean.com/community/tutorials/how-to-use-full-text-search-in-postgresql-on-ubuntu-16-04
Can I see an example of how this should be done with Neo4j?
You can do this using the APOC Neo4j procedure library. Let's say you have node labels Book and Author and you want to make a full text query across :Book(title), :Book(content), and :Author(name) and :Author(address). First, use apoc.index.addAllNodes to create an index called bookIndex and specify the labels and properties to include in the index:
CALL apoc.index.addAllNodes('bookIndex',{
Book: ["title","content"],
Author: ["name","address"]
})
Then, to search the index:
CALL apoc.index.search('bookIndex', 'River Runs Through It')
You can use this with more complex graph queries as well:
CALL apoc.index.search('bookIndex, 'River Runs Through It')
YIELD node AS book
MATCH (book)-[:IN_GENRE]->(g:Genre)
RETURN g
Lucene query syntax is used so you can do fuzzy search, required components of the string, etc: 'Norman Maclean~' or 'Norman~ +Maclean'
See the APOC docs for more info.

Where clause in fusion table query with google map javascript api v3

I want to put a fusion table layer over my google map using javascript api v3. There are four columns in it: iso, color, name, geometry. My fusion table is:
https://www.google.com/fusiontables/data?docid=1uO0anbhABVwjktSOy-PJsGo0Q4y-gTtzAe607c8
Why I can filter with: where: 'color=0'
but cannot filter with: where: 'iso="AU"'
'color' column type is number and 'iso' column type is text.
Any syntax error in that query? Thank you.
Oh, I find out why.
The where clause should be changed to where: "iso='AU'".
Double quotes should surround single quotes.

Resources