选择与elasticsearch不同(select distinct from elasticsearch)
我有一组文件,属于少数作者:
[ { id: 1, author_id: 'mark', content: [...] }, { id: 2, author_id: 'pierre', content: [...] }, { id: 3, author_id: 'pierre', content: [...] }, { id: 4, author_id: 'mark', content: [...] }, { id: 5, author_id: 'william', content: [...] }, ... ]
我想根据作者的id检索和分页最佳匹配文档的不同选择:
[ { id: 1, author_id: 'mark', content: [...], _score: 100 }, { id: 3, author_id: 'pierre', content: [...], _score: 90 }, { id: 5, author_id: 'william', content: [...], _score: 80 }, ... ]
这是我目前正在做的事情(伪代码):
unique_docs = res.results.to_a.uniq{ |doc| doc.author_id }
分页问题是正确的:如何选择20个“不同”的文件?
有些人指的是术语方面 ,但我实际上并没有做标签云:
- 使用CouchDB和elasticsearch进行不同的选择
- http://elasticsearch-users.115913.n3.nabble.com/Getting-Distinct-Values-td3830953.html
谢谢,
平硐I have a collection of documents which belongs to few authors:
[ { id: 1, author_id: 'mark', content: [...] }, { id: 2, author_id: 'pierre', content: [...] }, { id: 3, author_id: 'pierre', content: [...] }, { id: 4, author_id: 'mark', content: [...] }, { id: 5, author_id: 'william', content: [...] }, ... ]
I'd like to retrieve and paginate a distinct selection of best matching document based upon the author's id:
[ { id: 1, author_id: 'mark', content: [...], _score: 100 }, { id: 3, author_id: 'pierre', content: [...], _score: 90 }, { id: 5, author_id: 'william', content: [...], _score: 80 }, ... ]
Here's what I'm currently doing (pseudo-code):
unique_docs = res.results.to_a.uniq{ |doc| doc.author_id }
Problem is right on pagination: How to select 20 "distinct" documents?
Some people are pointing term facets, but I'm not actually doing a tag cloud:
- Distinct selection with CouchDB and elasticsearch
- http://elasticsearch-users.115913.n3.nabble.com/Getting-Distinct-Values-td3830953.html
Thanks,
Adit
原文:https://stackoverflow.com/questions/17949400
最满意答案
使用
Select-Object
在计算属性中调用Get-ADGroupMember
:$groups = Get-ADGroup -Filter * -SearchBase 'OU=BI-Security,OU=BH-Security Groups,DC=bh,DC=intra' $groups |Select-Object @{Expression={$_.Name};Label='Group Name'},@{Expression={@(Get-ADGroupMember -Identity $_|Select -Expand Name) -join ';'};Label='Name'} | Export-CSV C:\Scripts\BIGroups.CSV -NoTypeInformation -append
Call
Get-ADGroupMember
inside a calculated property withSelect-Object
:$groups = Get-ADGroup -Filter * -SearchBase 'OU=BI-Security,OU=BH-Security Groups,DC=bh,DC=intra' $groups |Select-Object @{Expression={$_.Name};Label='Group Name'},@{Expression={@(Get-ADGroupMember -Identity $_|Select -Expand Name) -join ';'};Label='Name'} | Export-CSV C:\Scripts\BIGroups.CSV -NoTypeInformation -append
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
您必须为每个用户创建对象并将其传递给Export-CSV cmdlet: $usersList | %{ # current logic $user = new-object psobject $user | add-member -membertype noteproperty -name LastLogon -value $last $user | add-member -membertype noteproperty -name ADName -value $ADName $user | add- ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
你可以使用EncodedCommand选项: $ScriptText = Get-Content C:\Path\To\Script.ps1 -Raw $ScriptBytes = [System.Text.Encoding]::Unicode.GetBytes($ScriptText) $EncCommand = [System.Convert]::ToBase64String($ScriptBytes) 现在复制$EncCommand的内容(例如使用$EncCommand |Set-ClipBoa ...
-
你可以很容易地简化这个: $Users = Get-ADGroup -SearchBase 'ou=XXX,ou=XXX,dc=XXX,dc=XXX,dc=org' -Filter * ` | Get-ADGroupMember -Recursive ` | Select-Object -Unique ` | Sort-Object DistinguishedName; $Users | Select-Object Name, DistinguishedName; Write-Out ...
-
Powershell Active Directory用户使用CSV到多个组(Powershell Active Directory Users to Multiple Groups using CSV)[2020-01-31]
正如在注释中已经指出的那样 ,使用-split运算符: foreach($user in $infoCSV) { foreach($group in $user.Groups -split ';') { Add-ADGroupMember -Identity $group -Members $user.sAMAccountName } } 如果这是PowerShell 2.0(版本3.0中引入了-split ),则可以使用String.Split()方法: fore ... -
将此任务分解为: 查找小组成员 确定它们是否驻留在OU中 使用Get-ADGroupMember轻松查找组成员: $Members = Get-ADGroupMember "SecurityGroup" 要确定成员是否驻留在OU中,请检查OU可分辨名称是否与成员的可分辨名称的最后部分匹配: $OU = "OU=Specific,OU=Computers,OU=Office1,DC=domain,DC=tld" $MembersInOu = $Members |Where-Object {$_.Disti ...
-
抱歉,我不认为您可以在Active Directory中使用DN comparaison中的通配符。 这里解释的ExtensibleMatch可能允许您在DN路径上构建过滤器,但在Active Directory中不支持它。 据我所知,你有以下解决方案来做你想做的事: 首先查找OU中的所有组,然后为每个组获取所有成员。 Sorry but I don't think that you can use wildcard caracters in DN comparaison in Active-Directo ...
-
使用Select-Object在计算属性中调用Get-ADGroupMember : $groups = Get-ADGroup -Filter * -SearchBase 'OU=BI-Security,OU=BH-Security Groups,DC=bh,DC=intra' $groups |Select-Object @{Expression={$_.Name};Label='Group Name'},@{Expression={@(Get-ADGroupMember -Identity $_|Se ...
-
为此,请使用PowerShell中的Active Directory模块。 您可以使用与此类似的脚本检索计算机名称: $City = Read-Host 'City' $ou = "OU=Workstations,OU=$City,DC=Fabrikam,DC=com" $Computers = Get-ADComputer -Filter '*' -SearchBase $ou $Computers | Foreach { $_.DNSHostName } | Out-File -Filepath " ...