parseFTAttributeFromMap parses an FTAttribute from a RESP3 map format
(attrMap map[interface{}]interface{})
| 1691 | |
| 1692 | // parseFTAttributeFromMap parses an FTAttribute from a RESP3 map format |
| 1693 | func parseFTAttributeFromMap(attrMap map[interface{}]interface{}) FTAttribute { |
| 1694 | att := FTAttribute{} |
| 1695 | for k, v := range attrMap { |
| 1696 | key := internal.ToLower(internal.ToString(k)) |
| 1697 | switch key { |
| 1698 | case "attribute": |
| 1699 | att.Attribute = internal.ToString(v) |
| 1700 | case "identifier": |
| 1701 | att.Identifier = internal.ToString(v) |
| 1702 | case "type": |
| 1703 | att.Type = internal.ToString(v) |
| 1704 | case "weight": |
| 1705 | att.Weight = internal.ToFloat(v) |
| 1706 | case "phonetic": |
| 1707 | att.PhoneticMatcher = internal.ToString(v) |
| 1708 | case "algorithm": |
| 1709 | att.Algorithm = internal.ToString(v) |
| 1710 | case "data_type": |
| 1711 | att.DataType = internal.ToString(v) |
| 1712 | case "dim": |
| 1713 | att.Dim = internal.ToInteger(v) |
| 1714 | case "distance_metric": |
| 1715 | att.DistanceMetric = internal.ToString(v) |
| 1716 | case "m": |
| 1717 | att.M = internal.ToInteger(v) |
| 1718 | case "ef_construction": |
| 1719 | att.EFConstruction = internal.ToInteger(v) |
| 1720 | case "flags": |
| 1721 | // flags is an array of strings like ["SORTABLE", "NOSTEM"] |
| 1722 | if flags, ok := v.([]interface{}); ok { |
| 1723 | for _, flag := range flags { |
| 1724 | flagStr := internal.ToLower(internal.ToString(flag)) |
| 1725 | switch flagStr { |
| 1726 | case "nostem": |
| 1727 | att.NoStem = true |
| 1728 | case "sortable": |
| 1729 | att.Sortable = true |
| 1730 | case "noindex": |
| 1731 | att.NoIndex = true |
| 1732 | case "unf": |
| 1733 | att.UNF = true |
| 1734 | case "case_sensitive": |
| 1735 | att.CaseSensitive = true |
| 1736 | case "withsuffixtrie": |
| 1737 | att.WithSuffixtrie = true |
| 1738 | } |
| 1739 | } |
| 1740 | } |
| 1741 | } |
| 1742 | } |
| 1743 | return att |
| 1744 | } |
| 1745 | |
| 1746 | // getMapStringKey extracts a string value from a map with interface{} keys |
| 1747 | func getMapStringKey(m map[interface{}]interface{}, key string) interface{} { |
no test coverage detected