private static CypherResult ExecuteMirrorGremlin(string script, AlgoContext context, int[] productIds)
        {
            try
            {
                Neo4jContext client = new Neo4jContext(false);
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                foreach (RecommendationContext item in context.Context.Keys)
                {
                    parameters["pMap" + item.ToString()] = context.Context[item];
                }

                if (productIds != null && productIds.Count() > 0)
                {
                    parameters["pMapProductsId"] = productIds;
                }

                string response = client.ExecuteGremlinScript(new Script {
                    ScriptStr = script, ParameterMap = parameters
                });
                return(JsonConvert.DeserializeObject <CypherResult>(response));
            }
            catch (Exception e)
            {
                Log.Error("ExecuteMirrorQuery", "Error executing query", e);
                throw;
            }
        }
Beispiel #2
0
 private void CreateNodeAndRelationships()
 {
     _context.ExecuteGremlinScript(new Script
     {
         ScriptStr = ParseGremlinQuery()
     });
 }
        public static CypherResult ExecuteGremlinRecommendation(string query, ContentTypeDistribution distribution, AggregateFilter filters, AlgoContext context, out string requestString)
        {
            try
            {
                string filteredQuery = BuildGremlinQuery(query, filters, distribution);
                Log.Debug("ExecuteGremlinRecommendation", "Query built from parameters");

                Neo4jContext client = new Neo4jContext(false);
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                foreach (RecommendationContext item in context.Context.Keys)
                {
                    parameters["pMap" + item.ToString()] = context.Context[item];
                }

                Script gremlinScript = new Script
                {
                    ScriptStr    = filteredQuery,
                    ParameterMap = parameters
                };

                string response = client.ExecuteGremlinScript(gremlinScript, out requestString);
                if (!string.IsNullOrEmpty(response))
                {
                    return(JsonConvert.DeserializeObject <CypherResult>(response));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                Log.Error("ExecuteRecommendationQuery", "Error executing query", e);
                throw;
            }
        }