@@ -1863,6 +1863,8 @@ Result RestReplicationHandler::processRestoreIndexes(VPackSlice const& collectio
1863
1863
return Result (TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
1864
1864
}
1865
1865
1866
+ VPackBuilder rebuilder;
1867
+
1866
1868
Result fres;
1867
1869
1868
1870
ExecContextSuperuserScope escope (ExecContext::current ().isAdminUser ());
@@ -1873,16 +1875,51 @@ Result RestReplicationHandler::processRestoreIndexes(VPackSlice const& collectio
1873
1875
auto physical = coll->getPhysical ();
1874
1876
TRI_ASSERT (physical != nullptr );
1875
1877
1876
- for (VPackSlice const & idxDef : VPackArrayIterator (indexes)) {
1877
- // {"id":"229907440927234","type":"hash","unique":false,"fields":["x","Y"]}
1878
- arangodb::velocypack::Slice value = idxDef.get (StaticStrings::IndexType);
1879
- if (value.isString ()) {
1880
- std::string const typeString = value.copyString ();
1881
- if ((typeString == " primary" ) || (typeString == " edge" )) {
1882
- LOG_TOPIC (" 0d352" , DEBUG, Logger::REPLICATION)
1883
- << " processRestoreIndexes silently ignoring primary or edge "
1884
- << " index: " << idxDef.toJson ();
1885
- continue ;
1878
+ for (VPackSlice idxDef : VPackArrayIterator (indexes)) {
1879
+ VPackSlice type = idxDef.get (StaticStrings::IndexType);
1880
+
1881
+ if (!type.isString ()) {
1882
+ // invalid type, cannot handle it
1883
+ continue ;
1884
+ }
1885
+
1886
+ if (type.isString () && (type.copyString () == " primary" || type.copyString () == " edge" )) {
1887
+ // must ignore these types of indexes during restore
1888
+ continue ;
1889
+ }
1890
+
1891
+ if (type.isEqualString (" geo1" ) || type.isEqualString (" geo2" )) {
1892
+ // transform type "geo1" or "geo2" into "geo".
1893
+ rebuilder.clear ();
1894
+ rebuilder.openObject ();
1895
+ rebuilder.add (StaticStrings::IndexType, VPackValue (" geo" ));
1896
+ for (auto const & it : VPackObjectIterator (idxDef)) {
1897
+ if (!it.key .isEqualString (StaticStrings::IndexType)) {
1898
+ rebuilder.add (it.key );
1899
+ rebuilder.add (it.value );
1900
+ }
1901
+ }
1902
+ rebuilder.close ();
1903
+ idxDef = rebuilder.slice ();
1904
+ }
1905
+
1906
+ if (type.isEqualString (" fulltext" )) {
1907
+ VPackSlice minLength = idxDef.get (" minLength" );
1908
+ if (minLength.isNumber ()) {
1909
+ int length = minLength.getNumericValue <int >();
1910
+ if (length <= 0 ) {
1911
+ rebuilder.clear ();
1912
+ rebuilder.openObject ();
1913
+ rebuilder.add (" minLength" , VPackValue (1 ));
1914
+ for (auto const & it : VPackObjectIterator (idxDef)) {
1915
+ if (!it.key .isEqualString (" minLength" )) {
1916
+ rebuilder.add (it.key );
1917
+ rebuilder.add (it.value );
1918
+ }
1919
+ }
1920
+ rebuilder.close ();
1921
+ idxDef = rebuilder.slice ();
1922
+ }
1886
1923
}
1887
1924
}
1888
1925
@@ -1976,16 +2013,58 @@ Result RestReplicationHandler::processRestoreIndexesCoordinator(VPackSlice const
1976
2013
1977
2014
auto & cluster = _vocbase.server ().getFeature <ClusterFeature>();
1978
2015
2016
+ VPackBuilder rebuilder;
2017
+
1979
2018
Result res;
1980
2019
1981
- for (VPackSlice const & idxDef : VPackArrayIterator (indexes)) {
2020
+ for (VPackSlice idxDef : VPackArrayIterator (indexes)) {
1982
2021
VPackSlice type = idxDef.get (StaticStrings::IndexType);
1983
2022
2023
+ if (!type.isString ()) {
2024
+ // invalid type, cannot handle it
2025
+ continue ;
2026
+ }
2027
+
1984
2028
if (type.isString () && (type.copyString () == " primary" || type.copyString () == " edge" )) {
1985
2029
// must ignore these types of indexes during restore
1986
2030
continue ;
1987
2031
}
1988
2032
2033
+ if (type.isEqualString (" geo1" ) || type.isEqualString (" geo2" )) {
2034
+ // transform type "geo1" or "geo2" into "geo".
2035
+ rebuilder.clear ();
2036
+ rebuilder.openObject ();
2037
+ rebuilder.add (StaticStrings::IndexType, VPackValue (" geo" ));
2038
+ for (auto const & it : VPackObjectIterator (idxDef)) {
2039
+ if (!it.key .isEqualString (StaticStrings::IndexType)) {
2040
+ rebuilder.add (it.key );
2041
+ rebuilder.add (it.value );
2042
+ }
2043
+ }
2044
+ rebuilder.close ();
2045
+ idxDef = rebuilder.slice ();
2046
+ }
2047
+
2048
+ if (type.isEqualString (" fulltext" )) {
2049
+ VPackSlice minLength = idxDef.get (" minLength" );
2050
+ if (minLength.isNumber ()) {
2051
+ int length = minLength.getNumericValue <int >();
2052
+ if (length <= 0 ) {
2053
+ rebuilder.clear ();
2054
+ rebuilder.openObject ();
2055
+ rebuilder.add (" minLength" , VPackValue (1 ));
2056
+ for (auto const & it : VPackObjectIterator (idxDef)) {
2057
+ if (!it.key .isEqualString (" minLength" )) {
2058
+ rebuilder.add (it.key );
2059
+ rebuilder.add (it.value );
2060
+ }
2061
+ }
2062
+ rebuilder.close ();
2063
+ idxDef = rebuilder.slice ();
2064
+ }
2065
+ }
2066
+ }
2067
+
1989
2068
VPackBuilder tmp;
1990
2069
1991
2070
res = ci.ensureIndexCoordinator (*col, idxDef, true , tmp, cluster.indexCreationTimeout ());
0 commit comments