display the search result from a particular path on top than other - aem

I have content structure as below
content
----- mysite
-------pathv1
------pathv2
My intention to display the result from the search path V1 before V2. The full-text search is returning randomly. I tried to use the orderby = path but it is not working.
Below is my query.
type=cq:Page
path=/content/mysite
fulltext=This is a test copy
p.limit = -1
1_orderby=path
2_orderby=#jcr:content/jcr:lastModified
orderby.sort=desc

Try to use #jcr:path instead of path:
type=cq:Page
path=/content/mysite
fulltext=This is a test copy
p.limit = -1
1_orderby=#jcr:path
2_orderby=#jcr:content/jcr:lastModified
1_orderby.sort=desc
2_orderby.sort=desc

Related

AEM search for files in DAM

I want to search files in my DAM folder using querybuilder. In my test folder, I have 1 .pptx file (powerpoint) and 1 .png file (image).
But when I run the below query, I get 3 results:
1. <PPTX file>/jcr:content
2. <PPTX file>.jcr:content/subassets/slide1/jcr:content
3 <image file>/jcr:content
The query is:
path=/content/dam/my-folder
type=dam:AssetContent
p.limit=-1
Are there any other predicates available to restrict this to 2 results, (files only) ?
I've tried "type=dam:Asset", but it gives 0 results. and "type=nt:base" gives 20 results
What you are looking for is the predicate mainasset. When you specify mainasset=true in your query it would ignore the subassets in the result. So, you can just search for type dam:Asset and specify the mainasset predicate as shown below.
path=/content/dam/my-folder
type=dam:Asset
mainasset=true
p.limit=-1
For more information on the list of available predicates in AEM, refer to this user guide.
Below AEM 6.3 -
Use path.flat predicate to narrow down the search to only the direct children and not the subtree.
path=/content/dam/we-retail/en/mahna
path.flat=true
type=dam:AssetContent
You can also use nodename predicate to query node names with a specific file extension
path=/content/dam/we-retail/en/mahna
type=dam:Asset
group.1_nodename=*.pptx
group.2_nodename=*.JPG
group.p.or=true

AEM CQ5 Query Builder: How to get result by searching for 2 different values in same property?

I want to get result matches with all nodes contains property 'abc' value as 'xyz' or 'pqr'.
I am trying in below ways:
http://localhost:4502/bin/querybuilder.json?path=/content/campaigns/asd&property=abc&property.1_value=/%xyz/%&property.2_value=/%pqr/%property.operation=like&p.limit=-1&orderby:path
http://localhost:4502/bin/querybuilder.json?path=/content/campaigns/asd&property=abc&property.1_value=/%xyz/%&property.2_value=/%pqr/%&property.1_operation=like&property.2_operation=like&p.limit=-1&orderby:path
http://localhost:4502/bin/querybuilder.json?path=/content/campaigns/asd&1_property=abc&1_property.1_value=/%xyz/%&1_property.1_operation=like&2_property=abc&1_property.1_value=/%xyz/%&2_property.1_operation=like&p.limit=-1&orderby:path
But none of them served my purpose. Any thing that I am missing in this?
The query looks right and as such should work. However if it is just xyz or pqr you would like to match in the query, you may not need the / in the values.
For eg.
path=/content/campaigns/asd
path.self=true //In order to include the current path as well for searching
property=abc
property.1_value=%xyz%
property.2_value=%abc%
property.operation=like
p.limit=-1
Possible things which you can check
Check if the path that you are trying to search contains the desired nodes/properties.
Check if the property name that you are using is right.
If you want to match exact values, you can avoid using the like operator and remove the wild cards from the values.
You can actually use the 'OR' operator in your query to combine two or more values of a property.
For example in the query debug interface : http:///libs/cq/search/content/querydebug.html
path=/content/campaigns/asd
property=PROPERTY1
property.1_value=VALUE1
property.2_value=VALUE2
property.operation=OR
p.limit=-1
It worked with below query:
http://localhost:4502/bin/querybuilder.json?orderby=path
&p.limit=-1
&path=/content/campaigns
&property=jcr:content/par/nodeName/xyz
&property.1_value=pqr
&property.2_value=%abc%
&property.operation=like
&type=cq:Page
Note: property name should be fully specified form the type of node we are expecting.
Ex: jcr:content/par/nodeName/xyz above instead of just xyz

Sphinx query/settings similar to Like '%string%' SQL query

I want to search for a string in Sphinx and get all documents that contains that string
Example: search for "bot" and get the documents that contain "xbot", "robot", "botanic", etc
Basically I want my search to have same effects as running a
SELECT * FROM table WHERE column_name LIKE '%bot%'
How can I do that?
Note:
I tried to use min_infix_len but it seems that is only extends the search a little bit but not fully. So if I set conf-min-prefix-len = 2 it will match 'xbot' but not "botanic"
Try using wildcard in Extended Query Syntax and min_infix_len enabled
SELECT * FROM myindex WHERE MATCH("bot | bot* | *bot*")

Having problems with Meteor regex query for Tree structure with materialzed paths

I have tree with materialized paths where I store the path with ids for each node:
path: ',tCENL4sLgfTPpNHqA,EDbvc7YD2MpBSz5RR,nh4HhHpdEwkeiXXw2,ENN8hsjnvxi23dp7q,ef4hptkM32ScASa73,i8QdauXtcqjyGCAX7,',
When I run the query directly on mongoDb I can find the results:
db.tree.find({path:/^,tCENL4sLgfTPpNHqA,/}).count();
But when I run the query through Meteor to get all the subtree for the root I do not get any results. I have run the following two queries with no results.
var rootPath = "/^," + rootNode._id + ",/";
Tree.find({path:rootPath}).fetch();
UPDATE
The problem is with generating the rootpath variable in separate chunks as string. If I replace the rootPath with a hardcoded id, it works.
So my question now is how to construct a regex on the fly with a variable?
To use variables in regex query building, use like this:
Tree.find({path:new RegExp(rootNode._id)}).fetch();

How can I use PowerShell to set the default document in IIS?

I'm configuring a web site using PowerShell and I want to set the default document. How do I do this?
This is one way:
$metabasePath = "IIS://Localhost/W3SVC"
$iisNumber = "12345"
$site = new-object
System.DirectoryServices.DirectoryEntry("$metabasePath/$iisNumber/root")
$site.psbase.Properties["DefaultDoc"].Value =
"newdefdoc.htm," + $site.psbase.Properties["DefaultDoc"].Value
$site.psbase.CommitChanges()
The value returned in $site.psbase.Properties["DefaultDoc"].Value is a comma separated list of documents so you may need to re-jig the order to suit your case. The example above just adds a new default document (newdefdoc.htm) to the top of the list.