首页 \ 问答 \ 两个以上字段值之和,并将其作为solr中的新字段返回(sum of more than two fields value and return it as new field in solr)

两个以上字段值之和,并将其作为solr中的新字段返回(sum of more than two fields value and return it as new field in solr)

嗨,我的solr中有多个docs,有一些整数类型的字段。 我想汇总这些字段并在新字段中返回其值。 我怎么能这样做。 以下是示例代码。

<doc>
    <field type="String" name="name">vinayak</field>
    <field type="int" name="roomRent">1000</field>
    <field type="int" name="electricityBill">500</field>
    <field type="int" name="food">2000</field>
    <field type="int" name="extra">500</field>
</doc>
<doc>
    <field type="String" name="name">sahil</field>
    <field type="int" name="roomRent">1500</field>
    <field type="int" name="electricityBill">700</field>
    <field type="int" name="food">2500</field>
    <field type="int" name="extra">1000</field>
</doc>

我想要一个查询返回我的结果跟随...

<doc>
    <field type="String" name="name">vinayak</field>
    <field type="int" name="totalCost">4000</field>
</doc>
<doc>
    <field type="String" name="name">sahil</field>
    <field type="int" name="totalCost">5700</field>
</doc>

我需要查询。

提前致谢。


Hi i have multiple docs in my solr having some fields of type integer. i want to summ these fields and return its value in new field. how can i do these. here following is example code.

<doc>
    <field type="String" name="name">vinayak</field>
    <field type="int" name="roomRent">1000</field>
    <field type="int" name="electricityBill">500</field>
    <field type="int" name="food">2000</field>
    <field type="int" name="extra">500</field>
</doc>
<doc>
    <field type="String" name="name">sahil</field>
    <field type="int" name="roomRent">1500</field>
    <field type="int" name="electricityBill">700</field>
    <field type="int" name="food">2500</field>
    <field type="int" name="extra">1000</field>
</doc>

i want a query which return me as result following...

<doc>
    <field type="String" name="name">vinayak</field>
    <field type="int" name="totalCost">4000</field>
</doc>
<doc>
    <field type="String" name="name">sahil</field>
    <field type="int" name="totalCost">5700</field>
</doc>

i need query.

Thanks in advance.


原文:https://stackoverflow.com/questions/39613180
更新时间:2022-03-22 11:03

最满意答案

您可以使用SQL Server Management Studio Express浏览它,并执行其他一些有用的操作,包括表格设计等。


You can use SQL Server Management Studio Express to browse it, and do several other useful things as well, including table design and the like.

相关问答

更多
  • SQL Server数据库使用两个文件 - 一个称为主数据库文件的MDF文件,其中包含模式和数据,以及包含日志的LDF文件。 见维基百科 数据库也可以使用辅助数据库文件,通常使用.ndf扩展名。 正如John S.所说,这些文件扩展名纯粹是惯例 - 你可以使用任何你想要的,尽管我不能想到一个很好的理由去做。 有关MSDN的更多信息,请参见开始SQL Server 2005管理(Google Books)。 SQL Server databases use two files - an MDF file, k ...
  • .MDF文件总是由SQL Server实例读取。 您的'db本地文件'实际上是由Visual Studio安装的SQL Server Express实例读取的。 SQL Server Express是一个完全成熟的SQL Server实例,在使用和许可方面有一些限制,但在所有方面都是SQL Server实例。 .MDF文件可以在Express和非Express实例之间随意复制。 分发应用程序时,还需要分发(或需要)SQL Server Express,请参阅分发SQL Server Express 。 如果 ...
  • 问题将解决,如果使一个Web托管一个新的数据库,然后Visual Studio只是连接到它。 从DDL当前基础和新设置下载它以节省时间。 您可能使用Windows主机站点。 如果你创建一个旧的或旧的转移 ,你可以这样做。 The problem will solve at the if the make a web-hosting a new database and then Visual Studio just connect to it. Download it from DDL current ba ...
  • 正如Erik所说,您已经在使用SQL服务器了。 您知道,我正在使用.MDF文件进行开发,一旦完成更改,我就将它们发布到生产环境中。 要做到这一点,您需要牢记以下几点。 尽管可能,但您不应使用此方法来替换/复制数据。 使用此方法可以轻松复制/更新架构。 应该可以从开发计算机访问生产数据库。 您需要Visual Studio来发布更改 我在下面的内容(所有步骤都在Visual Studio 2015 Update 3中 ): 在MDF文件中进行所需的任何更改。 在Visual Studio中打开“SQL Ser ...
  • 错误信息很明显.. 运行SQLServer的帐户无法访问问题中的共享。添加帐户并提供适当的权限 Error message is clear.. The Account under which SQLServer is running doesn't have access to the share in the question..Add the account and give appropriate permissions
  • 我已经尝试了几种方案来了解SQL服务器的工作方式。 结论是我们需要先分离并重新连接到相同或不同的机器(计算机)。 然后,我本可以成功移动到另一台计算机。 但是,将localdb备份和还原到另一台计算机(计算机)的单个进程不起作用。 此外,如果我们首先分离localdb(数据库文件.mdf),SQL服务器不再识别localdb数据库,我们无法为localdb运行backup命令。 确切而简单地说,如果我们想将localdb(microsoft数据库.mdf文件)移动到其他本地服务器(计算机,机器),我们需要从 ...
  • 您可以使用SQL Server Management Studio Express浏览它,并执行其他一些有用的操作,包括表格设计等。 You can use SQL Server Management Studio Express to browse it, and do several other useful things as well, including table design and the like.
  • 是的,不是。 这取决于你的SKU(具有讽刺意味的是,更昂贵的版本功能较差)。 SQL Server Standard / Enterprise:是的,但是您只能将CREATE DATABASE与指定为网络共享的DB路径一起使用,这意味着: 您需要在服务器上具有CREATE DATABASE权限(例如,是管理员或被分配的权限)。 对于SQL Server正在使用的用户帐户,网络共享需要NTFS和SMB的适当ACL。 SQL Server Standard或Enterprise不支持AttachDbFilena ...
  • 我尝试通过右键单击解决方案中的本地.mdf并选择“新查询”来运行这样的查询。 我不得不删除查询文本中的“use [test]”和所有“GO”,它正确地生成了我的表。 I tried running a query like this by right clicking on the local .mdf in the solution and choosing "New Query". I had to remove the "use [test]" and all the "GO"'s in the qu ...
  • 您的连接字符串告诉Sql Server Native Client ADO.NET Provider尝试连接到名为SQLEXPRESS的Sql Server实例,该实例将管理存储在文件DB.mdf中的数据库。 由于您的客户端计算机没有安装Sql Server Express,因此它不会找到要连接的数据库。 你需要: 在客户端计算机上安装Sql Server并在那里部署数据库。 切换到Sql Server Compact Edition(SqlCE - 嵌入式数据库)并重新构建应用程序以使用可移植数据库文件( ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)