forked from SolrNet/SolrNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
156 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,5 @@ SampleSolrApp/log* | |
_NCrunch*/* | ||
*~ | ||
packages/* | ||
.nuget/*.exe | ||
.nuget/*.exe | ||
*.sln.ide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using MbUnit.Framework; | ||
using SolrNet.Commands.Cores; | ||
using SolrNet.Utils; | ||
|
||
namespace SolrNet.Tests { | ||
[TestFixture] | ||
public class MergeCommandTests { | ||
[Test] | ||
public void Index() { | ||
var m = new MergeCommand("core0", new MergeCommand.IndexDir("/path/to/index1"), new MergeCommand.IndexDir("/path/to/index2")); | ||
var parameters = m.GetParameters().ToList(); | ||
Assert.Contains(parameters, KV.Create("action", "mergeindexes")); | ||
Assert.Contains(parameters, KV.Create("indexDir", "/path/to/index1")); | ||
Assert.Contains(parameters, KV.Create("indexDir", "/path/to/index2")); | ||
Assert.Contains(parameters, KV.Create("core", "core0")); | ||
} | ||
|
||
[Test] | ||
public void Core() { | ||
var m = new MergeCommand("core0", new MergeCommand.SrcCore("core1"), new MergeCommand.SrcCore("core2")); | ||
var parameters = m.GetParameters().ToList(); | ||
Assert.Contains(parameters, KV.Create("action", "mergeindexes")); | ||
Assert.Contains(parameters, KV.Create("srcCore", "core1")); | ||
Assert.Contains(parameters, KV.Create("srcCore", "core2")); | ||
Assert.Contains(parameters, KV.Create("core", "core0")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace SolrNet.Commands.Cores { | ||
/// <summary> | ||
/// Merges one or more cores into another core. | ||
/// See https://wiki.apache.org/solr/MergingSolrIndexes for details. | ||
/// </summary> | ||
public class MergeCommand: CoreCommand { | ||
/// <summary> | ||
/// Use an index path as merge source | ||
/// </summary> | ||
public sealed class IndexDir { | ||
/// <summary> | ||
/// Index directory | ||
/// </summary> | ||
public readonly string Dir; | ||
|
||
/// <summary> | ||
/// Use an index path as merge source | ||
/// </summary> | ||
/// <param name="dir">Index path</param> | ||
public IndexDir(string dir) { | ||
Dir = dir; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Use a core name as merge source | ||
/// </summary> | ||
public sealed class SrcCore { | ||
/// <summary> | ||
/// Core name | ||
/// </summary> | ||
public readonly string CoreName; | ||
|
||
/// <summary> | ||
/// Use a core name as merge source | ||
/// </summary> | ||
/// <param name="coreName">Core name</param> | ||
public SrcCore(string coreName) { | ||
CoreName = coreName; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Merge indexes using their path to identify them. | ||
/// Requires Solr 1.4+ | ||
/// </summary> | ||
/// <param name="destinationCore"></param> | ||
/// <param name="indexDir"></param> | ||
/// <param name="indexDirs"></param> | ||
public MergeCommand(string destinationCore, IndexDir indexDir, params IndexDir[] indexDirs) { | ||
AddParameter("core", destinationCore); | ||
AddParameter("action", "mergeindexes"); | ||
foreach (var d in new[] {indexDir}.Concat(indexDirs)) | ||
AddParameter("indexDir", d.Dir); | ||
} | ||
|
||
/// <summary> | ||
/// Merge indexes using their core names to identify them. | ||
/// Requires Solr 3.3+ | ||
/// </summary> | ||
/// <param name="destinationCore"></param> | ||
/// <param name="srcCore"></param> | ||
/// <param name="srcCores"></param> | ||
public MergeCommand(string destinationCore, SrcCore srcCore, params SrcCore[] srcCores) { | ||
AddParameter("core", destinationCore); | ||
AddParameter("action", "mergeindexes"); | ||
foreach (var c in new[] {srcCore}.Concat(srcCores)) | ||
AddParameter("srcCore", c.CoreName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters