I'm trying to create index from table domains. When I get 10 attributes, everything is ok. When i add 11-th, indexer returns:
collected 1629494 docs, 0.0 MB
Config:
#...
sql_attr_uint = did
sql_attr_string = url
sql_attr_uint = zone_id
sql_attr_uint = first_letter
sql_attr_uint = category_id
sql_attr_uint = is_parking
#sql_attr_uint = data3
sql_attr_uint = views
sql_attr_uint = data1
sql_attr_uint = data2
sql_attr_uint = is_top_site
#...
When I remove any of the 11 attributes, everything works fine. Is there some kind of limit ?
Related
I have created realtime index:
index berni_filter2
{
rt_mem_limit = 512M
type = rt
path = /var/lib/sphinxsearch/data/berni_filter
rt_attr_uint = product_id
rt_attr_uint = store_id
rt_field = product_name
rt_attr_json = attributes
prefix_fields = product_name
expand_keywords = 1
min_infix_len = 2
dict = keywords
}
Then I trying to get data by product name field over SphinxQL:
SELECT product_id FROM berni_filter2 WHERE store_id = 0 AND MATCH ('#product_name mothercare')
This query work fine, but I need to find partically words, for example "mother" must return products with "mothercare". I have tried:
SELECT product_id FROM berni_filter2 WHERE store_id = 0 AND MATCH ('#product_name mother')
SELECT product_id FROM berni_filter2 WHERE store_id = 0 AND MATCH ('#product_name mother*')
SELECT product_id FROM berni_filter2 WHERE store_id = 0 AND MATCH ('#product_name *mother*')
I tried change min_infix_len to min_prefix_len. Nothing work.
My mistake was, that I don't delete data files from filesystem, when change config, this is final working config:
index berni_filter
{
rt_mem_limit = 512M
type = rt
path = /var/lib/sphinxsearch/data/berni_filter
rt_attr_uint = product_id
rt_attr_uint = store_id
rt_field = product_name
rt_attr_json = attributes
index_exact_words = 1
expand_keywords = 1
min_prefix_len = 3
min_word_len = 2
morphology = stem_enru
dict = keywords
}
I faced the same problem. Deleting the index files helps me too.
Before deleting I stop the searchd service and then restart it.
SELECT (
SELECT SUM(qty)
FROM sk_lgr_hd
WHERE item_id = 4
AND tra_type = 'OS'
AND dept_id = 7
) + (
SELECT SUM(qty)
FROM sk_lgr_hd
WHERE item_id = 4
AND tra_type = 'IR'
AND dept_id = 7
) - (
SELECT SUM(qty)
FROM sk_lgr_hd
WHERE item_id = 4
AND tra_type = 'IS'
AND dept_id = 7
)
I can Get sum still i need to get dept_id,tra_type,id,..
i need some thing like this.
sum dept_id id
20 2 3
I would like to select users,in which groups they belong to, and their sites. I want it with a single postgre sql query.
I've found these queries, but i want them combined with join if possible.
select * from alf_permission
select * from ALF_AUTHORITY
select * from ALF_CHILD_ASSOC where CHILD_NODE_NAME like ‘group%’
select * from ALF_CHILD_ASSOC where QNAME_LOCALNAME like ‘GROUP%’
select
node_id,
string_agg(string_value, ',')
from (
select
node_id,
qname_id,
(select local_name from alf_qname where id = qname_id) as qname_type,
string_value
from alf_node_properties
where node_id in (
select id from alf_node
where type_qname_id = (
select id from alf_qname where local_name = 'person'
)
and qname_id in (
select id
from alf_qname
where local_name in (
'username',
'firstName',
'lastName',
'email'
)
)
)
) alf_users
group by node_id;
I would advise to create webscript possibly in Java that will do this fast and efficient!
I found a solution!
I put the script in Company Home > Data Dictionary > Web Scripts > org > alfresco > test
As you can see i created the "test" folder in "alfresco" folder, and in it i put these three files.
hello.get.html.ftl file
<table border>
<tr>
<th>Username</th>
<th>Groups</th>
<th>Sites</th>
</tr>
<#list test as child>
<tr>
<td>${child['username']}</td>
<td>${child['groups']}</td>
<td>${child['sites']}</td>
</tr>
</#list>
</table>
hello.get.desc.xml
<webscript>
<shortname>Hello</shortname>
<description>Polite greeting</description>
<url>/test/hello</url>
<authentication>user</authentication>
</webscript>
hello.get.js
var gens = search.luceneSearch("TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"");
var a = [];
for (var i=0; i<gens.length;i++) {
var username = gens[i].properties["cm:userName"];
var b = [];
var groups = people.getContainerGroups(gens[i]);
for(var j=0; j<groups.length; j++) {
b.push(groups[j].properties['authorityDisplayName']);
}
var sites = siteService.listUserSites(username);
var g=[]
for(var j=0; j<sites.length; j++) {
g.push(sites[j]['shortName']);
}
//a.push('\n\n\n'+username+'\groups--> '+ b.join(', ') + '\nsites--> '+g.join(', '));
a.push({
'username' : username,
'groups' : b.join(', '),
'sites' : g.join(', ')
})
}
model.test = a;
you can access the result in your_domain_name/alfresco/service/test/hello
Try this query to get persons and groups
select
ca.id,
ca.parent_node_id,
ca.child_node_id,
ca.qname_localname,
np.string_value
from alf_child_assoc as ca
join alf_node as child on child.id = ca.child_node_id
join alf_node as parent on parent.id = ca.parent_node_id
join alf_qname as q1 on q1.id = parent.type_qname_id
join alf_qname as q2 on q2.id = child.type_qname_id
join alf_node_properties as np on np.node_id = parent.id
where q1.local_name = 'authorityContainer'
and q2.local_name = 'person'
and np.qname_id = (select id from alf_qname where local_name =
'authorityDisplayName')
order by ca.qname_localname;`
Could I search with sphinx only by attributes without query word
config:
sql_query = SELECT p.ID as price_id, p.info, p.sort_id, p.made_id, p.category_id, 'prices' as table_id FROM price AS p
sql_query_info = SELECT * FROM price WHERE ID = $id
sql_attr_uint = sort_id
...
min_word_len = 0
min_infix_len = 0
min_prefix_len = 0
enable_star = 1
docinfo = extern
code:
$search->SetFilter('sort_id',[1,2]);
$search->Query("*","prices");
Get 0 results
$search->Query("","prices");
If that returns no results, you've got some other logic error.
Tangential, why are you 'enable_star' with infix/prefix set to 0? It will have no effect.
I have these two queries and I want one set of results combining top 5 results for TP and top 5 results for LP.
I really do not know how to explain this more clearly, I have two sets of results, top 5 for LP and top 5 for TP and I would like to have a set of results Incident_TP, IncidentID_TP, IncidentHappenedDate_TP , IncidentNumber_TP , LossValue_TP , RecoveredValue_TP , TotalLoss_TP , Incident_LP, IncidentID_LP, IncidentHappenedDate_LP , IncidentNumber_LP , LossValue_LP , RecoveredValue_LP , TotalLoss_LP
DECLARE #IncidentFromDate_TP DATE = '2011-1-12'
DECLARE #IncidentToDate_TP DATE = '2012-1-12'
DECLARE #IncidentFromDate_LP DATE = '2010-1-12'
DECLARE #IncidentToDate_LP DATE = '2011-1-12'
SELECT TOP 5
Incident_TP = Incident_TP.IncidentID
, IncidentHappenedDate_TP = Incident_TP.IncidentHappenedDate
, IncidentNumber_TP = Incident_TP.IncidentNumber
, LossValue_TP = Incident_TP.TotalLoss
, RecoveredValue_TP = Incident_TP.TotalRecovered
, TotalLoss_TP = Incident_TP.CostOfIncident
FROM
Incident AS Incident_TP
INNER JOIN Site AS Site_TP ON Incident_TP.SiteID = Site_TP.SiteID
INNER JOIN Region AS Region_TP ON Site_TP.RegionID = Region_TP.RegionID
WHERE
Incident_TP.TotalLoss > 0.00
AND Incident_TP.IncidentHappenedDate BETWEEN #IncidentFromDate_TP AND #IncidentToDate_TP
ORDER BY
TotalLoss_TP DESC
, IncidentHappenedDate_TP DESC
SELECT TOP 5
Incident_LP = Incident_LP.IncidentID
, IncidentHappenedDate_LP = Incident_LP.IncidentHappenedDate
, IncidentNumber_LP = Incident_LP.IncidentNumber
, LossValue_LP = Incident_LP.TotalLoss
, RecoveredValue_LP = Incident_LP.TotalRecovered
, TotalLoss_LP = Incident_LP.CostOfIncident
FROM
Incident AS Incident_LP
INNER JOIN Site ON Incident_LP.SiteID = Site.SiteID
INNER JOIN Region ON Site.RegionID = Region.RegionID
WHERE
Incident_LP.TotalLoss > 0.00
AND Incident_LP.IncidentHappenedDate BETWEEN #IncidentFromDate_LP AND #IncidentToDate_TP
ORDER BY
TotalLoss_LP DESC
, IncidentHappenedDate_LP DESC
Many thanks
As Tim suggests you could union the sets together, For example:
DECLARE #IncidentFromDate_TP DATE = '2011-1-12';
DECLARE #IncidentToDate_TP DATE = '2012-1-12';
DECLARE #IncidentFromDate_LP DATE = '2010-1-12';
DECLARE #IncidentToDate_LP DATE = '2011-1-12';
WITH RawData
AS ( SELECT Incident_TP = Incident_TP.IncidentID ,
IncidentHappenedDate_TP = Incident_TP.IncidentHappenedDate ,
IncidentNumber_TP = Incident_TP.IncidentNumber ,
LossValue_TP = Incident_TP.TotalLoss ,
RecoveredValue_TP = Incident_TP.TotalRecovered ,
TotalLoss_TP = Incident_TP.CostOfIncident
FROM Incident AS Incident_TP
INNER JOIN Site AS Site_TP ON Incident_TP.SiteID = Site_TP.SiteID
INNER JOIN Region AS Region_TP ON Site_TP.RegionID = Region_TP.RegionID
WHERE Incident_TP.TotalLoss > 0.00
),
TopFiveSetA
AS ( SELECT TOP 5
*
FROM RawData
WHERE IncidentHappenedDate_TP BETWEEN #IncidentFromDate_TP
AND #IncidentToDate_TP
ORDER BY TotalLoss_TP DESC ,
IncidentHappenedDate_TP DESC
),
TopFiveSetB
AS ( SELECT TOP 5
*
FROM RawData
WHERE IncidentHappenedDate_TP BETWEEN #IncidentFromDate_LP
AND #IncidentToDate_LP
ORDER BY TotalLoss_TP DESC ,
IncidentHappenedDate_TP DESC
),
Merged
AS ( SELECT *
FROM TopFiveSetA
UNION ALL
SELECT *
FROM TopFiveSetB
)
SELECT *
FROM Merged