Commit 689160bb by mahaisong

fix:测试NEST6改变标签后的功能和put的功能。

parent e6994ca2
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
...@@ -4,14 +4,21 @@ ...@@ -4,14 +4,21 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<!--<connectionStrings>
--><!--测试stringtext--><!--
--><!--<add name="ESDatabase" connectionString="host=mech.palaspom.com|tank.palaspom.com;port=19235;defaultIndex=palas;requesttimeout=0:1:00;version=2;" />--><!--
</connectionStrings>-->
<connectionStrings> <connectionStrings>
<!--必选:20187150点迁移完成前保留-->
<!--必选:20187150点迁移完成前保留-->
<add name="2ESDatabase" connectionString="host=127.0.0.1|localhost;port=9200;defaultindex=test;requesttimeout=0:1:00;version=2;" /> <add name="2ESDatabase" connectionString="host=127.0.0.1|localhost;port=9200;defaultindex=test;requesttimeout=0:1:00;version=2;" />
<!--必选:(全部小写)6没有defaultindexIndex:palas前缀字符+“_”+type --> <!--必选:(全部小写)6没有defaultindexIndex:palas前缀字符+“_”+type-->
<add name="ESDatabase" connectionString="host=minder;port=9200;requesttimeout=0:1:00;version=6;indexprefix=test_;" /> <add name="ESDatabase" connectionString="host=minder;port=9200;requesttimeout=0:1:00;version=6;indexprefix=test_;" />
......
using Nest2_5_8;
using Nest2_5_8;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnitTestProject
{
/// <summary>
/// 反馈信息
/// </summary>
[ElasticsearchType(Name = "feedbacks")]
public class FeedbackModel
{
/// <summary>
/// 用户编号
/// </summary>
public string UserId { set; get; }
/// <summary>
/// 反馈内容
/// </summary>
public string Content { set; get; }
/// <summary>
/// 创建时间
/// </summary>
public long CreateTime { set; get; }
/// <summary>
/// 反馈编号
/// </summary>
public string FeedbackID { set; get; }
/// <summary>
/// 反馈包含图片
/// </summary>
public List<string> Images { set; get; }
/// <summary>
/// 反馈的回复,为了降低复杂度,回复暂时没有层级关系,按照时间排序
/// </summary>
[Nested(CopyTo = "replys")]
public List<FeedbackModel> Replys { set; get; }
}
//[ElasticsearchType(Name = "boolwriting")]
//public class BoolWriting
//{
// public string BoolPushID { get; set; }
// public string AbilityName { get; set; }
// [Text(Name = "stockName")]
// public string Name { get; set; }
// [Number(Name = "pubDateTimeStamp")]
// public long PubDate { get; set; }
// [Text(Name = "tendency1")]
// public string Tendency { get; set; }
// [Text(Name = "typename")]
// public string Type { get; set; }
// public string FinancialName { get; set; }
// [Text(Name = "status1")]
// public string Status { get; set; }
// [Text(Name = "ability1")]
// public string Ability { get; set; }
// [Text(Name = "codeNum")]
// public string Code { get; set; }
// [Text(Name = "pushContent")]
// public string Content { get; set; }
// [Text(Name = "value1")]
// public double Value { get; set; }
// public int Pushing { get; set; }
//}
}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
<Reference Include="Elasticsearch.Net, Version=6.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d, processorArchitecture=MSIL"> <Reference Include="Elasticsearch.Net, Version=6.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d, processorArchitecture=MSIL">
<HintPath>..\packages\Elasticsearch.Net.6.1.0\lib\net46\Elasticsearch.Net.dll</HintPath> <HintPath>..\packages\Elasticsearch.Net.6.1.0\lib\net46\Elasticsearch.Net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Elasticsearch.Net2_5_8">
<HintPath>..\..\includees\Elasticsearch.Net2_5_8.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> <HintPath>..\packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference> </Reference>
...@@ -50,6 +53,9 @@ ...@@ -50,6 +53,9 @@
<Reference Include="Nest, Version=6.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d, processorArchitecture=MSIL"> <Reference Include="Nest, Version=6.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d, processorArchitecture=MSIL">
<HintPath>..\packages\NEST.6.1.0\lib\net46\Nest.dll</HintPath> <HintPath>..\packages\NEST.6.1.0\lib\net46\Nest.dll</HintPath>
</Reference> </Reference>
<Reference Include="Nest2_5_8">
<HintPath>..\..\includees\Nest2_5_8.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
...@@ -57,6 +63,8 @@ ...@@ -57,6 +63,8 @@
<Reference Include="System.Core" /> <Reference Include="System.Core" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Author.cs" />
<Compile Include="BoolWriting.cs" />
<Compile Include="ES6.cs" /> <Compile Include="ES6.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitTestES6-2.cs" /> <Compile Include="UnitTestES6-2.cs" />
......
using System; using System;
...@@ -3,6 +3,9 @@ using System.Text; ...@@ -3,6 +3,9 @@ using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestES6_2; using TestES6_2;
using Nest;
using HTCommon.Helper;
using System.Linq;
namespace UnitTestProject namespace UnitTestProject
{ {
...@@ -37,6 +40,85 @@ namespace UnitTestProject ...@@ -37,6 +40,85 @@ namespace UnitTestProject
} }
} }
[TestMethod]
public void testAuthortext()
{
// int i = 5;
// Author item6 = new Author();
// //将数据构造为ITEM。
// item6.AuthorIDTest = "DeleteTestOracleBeigeNEWS";
//var t12 = ESAccess.Index<Author>(item6);
Nest.SearchDescriptor<Author> builder6 = new Nest.SearchDescriptor<Author>()
.Query(q => q.MatchAll());
List<Author> list = ESAccess.Search(builder6).ToList<Author>();
Console.ReadLine();
}
public static List<BoolWriting> GetBoolWritingBywhere(DateTime? PubDate, string boolPushID)
{
SearchDescriptor<BoolWriting> builder = new SearchDescriptor<BoolWriting>();
QueryContainer query = null;
//发布时间小于等于结束时间
if (PubDate == null)
PubDate = DateTime.Now;
if (!string.IsNullOrEmpty(boolPushID))
{
query &= Query<BoolWriting>.QueryString(r => r.DefaultField(f => f.BoolPushID).Query(boolPushID));
}
else
{
query &= Query<BoolWriting>.Range(r => r.Field(f => f.PubDate)
.LessThanOrEquals(DateTimeUtility.GetUnixTimeStamp(((DateTime)PubDate).AddYears(-10)))
.GreaterThanOrEquals(DateTimeUtility.GetUnixTimeStamp(((DateTime)PubDate).AddDays(-1))));
}
query &= Query<BoolWriting>.Term(t => t.Pushing, 1);
query &= Query<BoolWriting>.QueryString(t => t.DefaultField(f => f.Content).Query("*"));
builder.Sort(s => s.Descending(f => f.PubDate));
//分页
builder.From(0);
builder.Size(1);
builder.Query(f => query);
try
{
return ESAccess.Search(builder).ToList();
}
catch (Exception ex)
{
}
return null;
}
[TestMethod]
public void testboolWritingList()
{
List<BoolWriting> boolWritingList = GetBoolWritingBywhere(DateTime.Now.AddMonths(-1), null);
if (boolWritingList != null && boolWritingList.Count > 0)
{
}
}
#region 附加测试特性 #region 附加测试特性
// //
// 编写测试时,可以使用以下附加特性: // 编写测试时,可以使用以下附加特性:
...@@ -151,7 +233,7 @@ namespace UnitTestProject ...@@ -151,7 +233,7 @@ namespace UnitTestProject
int i = 7; int i = 7;
HTCommon.Data6.Item item6 = new HTCommon.Data6.Item(); HTCommon.Data6.Item item6 = new HTCommon.Data6.Item();
//将数据构造为ITEM。 //将数据构造为ITEM。
item6.Crawler = "DeleteTestOracleBeigeNEWS"; item6.Crawler = "DeleteTestOracleBeigeNEWS";
...@@ -180,14 +262,14 @@ namespace UnitTestProject ...@@ -180,14 +262,14 @@ namespace UnitTestProject
// ESAccess.BulkInsert<HTCommon.Data6.Item>(array); // ESAccess.BulkInsert<HTCommon.Data6.Item>(array);
ESAccess.BulkInsert<HTCommon.Data6.Item>(array, "other_items"); ESAccess.BulkInsert<HTCommon.Data6.Item>(array, "other_items");
} }
[TestMethod] [TestMethod]
public void BulkInsertTest() public void BulkInsertTest()
{ {
int i =8; int i = 8;
HTCommon.Data6.Item item6 = new HTCommon.Data6.Item(); HTCommon.Data6.Item item6 = new HTCommon.Data6.Item();
...@@ -291,12 +373,12 @@ namespace UnitTestProject ...@@ -291,12 +373,12 @@ namespace UnitTestProject
item6.Tag = "MinderESFromBeigeOracle"; item6.Tag = "MinderESFromBeigeOracle";
item6.ItemID = "test" + i.ToString(); item6.ItemID = "test" + i.ToString();
//测试目的。1.6前缀自动插入。 2.非前缀,指定other查询。 //测试目的。1.6前缀自动插入。 2.非前缀,指定other查询。
//ESAccess.IndexOnly<HTCommon.Data6.Item>(item6); //ESAccess.IndexOnly<HTCommon.Data6.Item>(item6);
ESAccess.IndexOnly<HTCommon.Data6.Item>(item6,"", "other_items"); ESAccess.IndexOnly<HTCommon.Data6.Item>(item6, "", "other_items");
} }
...@@ -331,7 +413,7 @@ namespace UnitTestProject ...@@ -331,7 +413,7 @@ namespace UnitTestProject
//ESAccess.IndexOnlyDetail<HTCommon.Data6.Item>(item6); //ESAccess.IndexOnlyDetail<HTCommon.Data6.Item>(item6);
ESAccess.IndexOnly<HTCommon.Data6.Item>(item6, "", "other_items"); ESAccess.IndexOnly<HTCommon.Data6.Item>(item6, "", "other_items");
} }
[TestMethod] [TestMethod]
public void SearchTop() public void SearchTop()
...@@ -345,8 +427,8 @@ namespace UnitTestProject ...@@ -345,8 +427,8 @@ namespace UnitTestProject
//var t1 = ESAccess.SearchTop(builder6); //var t1 = ESAccess.SearchTop(builder6);
var t2 = ESAccess.SearchTop(builder6, "other_items"); var t2 = ESAccess.SearchTop(builder6, "other_items");
} }
catch (Exception ex) catch (Exception ex)
...@@ -373,9 +455,9 @@ namespace UnitTestProject ...@@ -373,9 +455,9 @@ namespace UnitTestProject
[TestMethod] [TestMethod]
public void CountStr() public void CountStr()
{ {
string query= "{\"from\":0,\"size\":0,\"query\":{\"match_all\":{}}}"; string query = "{\"from\":0,\"size\":0,\"query\":{\"match_all\":{}}}";
//private,观察函数无误,暂不测试 //private,观察函数无误,暂不测试
} }
[TestMethod] [TestMethod]
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
...@@ -4,14 +4,21 @@ ...@@ -4,14 +4,21 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<!--<connectionStrings>
--><!--测试stringtext--><!--
--><!--<add name="ESDatabase" connectionString="host=mech.palaspom.com|tank.palaspom.com;port=19235;defaultIndex=palas;requesttimeout=0:1:00;version=2;" />--><!--
</connectionStrings>-->
<connectionStrings> <connectionStrings>
<!--必选:20187150点迁移完成前保留-->
<!--必选:20187150点迁移完成前保留-->
<add name="2ESDatabase" connectionString="host=127.0.0.1|localhost;port=9200;defaultindex=test;requesttimeout=0:1:00;version=2;" /> <add name="2ESDatabase" connectionString="host=127.0.0.1|localhost;port=9200;defaultindex=test;requesttimeout=0:1:00;version=2;" />
<!--必选:(全部小写)6没有defaultindexIndex:palas前缀字符+“_”+type --> <!--必选:(全部小写)6没有defaultindexIndex:palas前缀字符+“_”+type-->
<add name="ESDatabase" connectionString="host=minder;port=9200;requesttimeout=0:1:00;version=6;indexprefix=test_;" /> <add name="ESDatabase" connectionString="host=minder;port=9200;requesttimeout=0:1:00;version=6;indexprefix=test_;" />
......
9fc15fed46774ac0d1ca970d3dbe672124b50dd8 edbee5aaa8d2f637fb9b9c16b990e1ec2a89fc86
9fc15fed46774ac0d1ca970d3dbe672124b50dd8 edbee5aaa8d2f637fb9b9c16b990e1ec2a89fc86
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment