coronabytes / dotnet-arangodb

.NET Driver for ArangoDB
Apache License 2.0
66 stars 18 forks source link

Arango Search view, setting IncludeAllFields #66

Closed bbm-design closed 1 year ago

bbm-design commented 1 year ago

i have created a view using this piece of code

 if ((await _arango.View.ListAsync(StaticDBIdentifiers.DBName)).Where(o => o.Name == StaticDBIdentifiers.ViewProductWithSort).ToList().Count() <= 0)
                    await _arango.View.CreateAsync(StaticDBIdentifiers.DBName, new ArangoView
                    {
                        Name = StaticDBIdentifiers.ViewProductWithSort,
                        Links = new Dictionary<string, ArangoLinkProperty>
                        {
                            [StaticDBIdentifiers.Vertexes.Product] = new ArangoLinkProperty
                            {
                                Fields = new Dictionary<string, ArangoLinkProperty>
                                {
                                    ["name"] = new ArangoLinkProperty
                                    {
                                        Analyzers = new List<string>
                                        {
                                            StaticDBIdentifiers.AnalyzerNgram,
                                            StaticDBIdentifiers.AnalyzerTokenizer
                                        },
                                        IncludeAllFields = true
                                    },
                                    ["description"] = new ArangoLinkProperty
                                    {
                                        Analyzers = new List<string>
                                        {
                                            StaticDBIdentifiers.AnalyzerNgram,
                                            StaticDBIdentifiers.AnalyzerTokenizer
                                        }
                                    },
                                }
                            }
                        },
                        PrimarySort = new List<ArangoSort>
                        {
                            new ArangoSort
                            {
                                Field = "creationDate",
                                Direction = ArangoSortDirection.Desc,
                            }
                        }
                    });

once executed, i get this

{
  "writebufferSizeMax": 33554432,
  "id": "6513316",
  "storedValues": [],
  "name": "ViewPartnerWithSort",
  "type": "arangosearch",
  "consolidationPolicy": {
    "type": "tier",
    "segmentsBytesFloor": 2097152,
    "segmentsBytesMax": 5368709120,
    "segmentsMax": 10,
    "segmentsMin": 1,
    "minScore": 0
  },
  "writebufferActive": 0,
  "links": {
    "Partner": {
      "analyzers": [
        "identity"
      ],
      "fields": {
        "name": {
          "analyzers": [
            "BBMAnalyzerNgram",
            "BBMAnalyzerTokenizer"
          ]
        },
        "description": {
          "analyzers": [
            "BBMAnalyzerNgram",
            "BBMAnalyzerTokenizer"
          ]
        }
      },
      "includeAllFields": false,
      "storeValues": "none",
      "trackListPositions": false
    }
  },
  "commitIntervalMsec": 1000,
  "consolidationIntervalMsec": 1000,
  "globallyUniqueId": "h396FF17F2DDD/6513316",
  "cleanupIntervalStep": 2,
  "primarySort": [
    {
      "field": "creationDate",
      "asc": false
    }
  ],
  "primarySortCompression": "lz4",
  "writebufferIdle": 64
}

i'm either using it the wrong way, or there is something wrong with the setter

bbm-design commented 1 year ago

update :

Had to define it one step higher, it could lead to confusion, but i'll leave it here in case it could help someone else

if ((await _arango.View.ListAsync(StaticDBIdentifiers.DBName)).Where(o => o.Name == StaticDBIdentifiers.ViewProductWithSort).ToList().Count() <= 0)
                    await _arango.View.CreateAsync(StaticDBIdentifiers.DBName, new ArangoView
                    {
                        Name = StaticDBIdentifiers.ViewProductWithSort,
                        Links = new Dictionary<string, ArangoLinkProperty>
                        {
                            [StaticDBIdentifiers.Vertexes.Product] = new ArangoLinkProperty
                            {
                                IncludeAllFields = true,
                                Fields = new Dictionary<string, ArangoLinkProperty>
                                {
                                    ["name"] = new ArangoLinkProperty
                                    {
                                        Analyzers = new List<string>
                                        {
                                            StaticDBIdentifiers.AnalyzerNgram,
                                            StaticDBIdentifiers.AnalyzerTokenizer
                                        },
                                    },
                                    ["description"] = new ArangoLinkProperty
                                    {
                                        Analyzers = new List<string>
                                        {
                                            StaticDBIdentifiers.AnalyzerNgram,
                                            StaticDBIdentifiers.AnalyzerTokenizer
                                        }
                                    },
                                }
                            }
                        },
                        PrimarySort = new List<ArangoSort>
                        {
                            new ArangoSort
                            {
                                Field = "creationDate",
                                Direction = ArangoSortDirection.Desc,
                            }
                        }
                    });