Unexpected results when using a query

Hey All,

I'm having some problems understanding the inner workings of the Graph API, especially when using search queries.
It's ginving me some results I wouldn't expect and i'm not sure if i'm running into a bug or limitation, or if I'm just not getting it :slight_smile:

For example, I have a dataset with meetup members (downloaded with the meetup.com api), containing their interests, city, country, gender, etc.

I've selected the fields city and interests to get a nice graph of interests connected to each other, cities connected to interests. and the resulting graph looks as expected:

Now I want the graph api to create a graph for me only containing the interests in the city of Amsterdam, so I clear the graph, keep the selected fields and enter the query city:Amsterdam.

Again, the graph looks as expected:

However, when I start expanding nodes, for instance the 'web development' node, I get (at least for me) unexpected results back:

As you see, the 'web development' node is connected to multiple cities (San Fransisco, Brussels).
Why would the graph api return those cities when I explicitly filtered on the city of Amsterdam (excluding all records having values other than Amsterdam)?

To be clear, the city field is a single value field, there are no records with multiple values in the city field.

Thanks and best regards,

Rienk Prinsen

In the GUI, your query is only the seed to get you started. You could, for example have started with "angular" as a query, not knowing anything about that technology and expanded out into "javascript" and from there "jquery" etc.
In the Graph API there is the option of a guiding query [1] that can be used as a constant as you explore out further into the graph but that is not currently exposed in the user interface.

[1] REST API | Elasticsearch Graph [2.4] | Elastic

Ah, thanks for your quick reply Mark!

i was under the presumption I'd use the search query to select a document set (like a regular aggregation), from which the graph api would generate a graph that I could explore.

But it looks like the graph api creates a graph on the full dataset (is it?), and uses the search query to select a starting point?

Can this guiding query be used as a hard filter? For instance, only explore to nodes who are connected by documents with the field "gender:male"?

Yes - exploration typically starts with a query and finds strongly connected terms, then each exploration out from these vertices uses these terms as a query to find more terms and so on.

Using the API, yes it is possible that you can provide such a query to "guide" the exploration so rather than looking for connections in docs that contain vertex terms A OR B it would effectively be searching for (A OR B) AND gender:male.

1 Like

That's a really useful addition!
That would indeed solve my first problem of only wanting to explore connections within Amsterdam.

The main thing I was struggling with while using the api and the kibana plugin was actually controlling the starting point and traversal of the graph.
It always seemed to return 'relevant' nodes, which is nice when randomly exploring the data.
But when you actually want to do a controlled traversal (similar when using a graph database), you really need some more precise controls :slight_smile:

And it looks like i can use the search query to select the starting point by searching by id, and then do the controlled traversal by using the guiding query.