Filtering GetEntries by another Entry ID's existence within array of links attribute - contentful

I have a content type post where the entries have a categories attribute, which is an Array of Links (to a category content type).
I want to fetch all posts that have been tagged with a certain category. That is, Post entries where fields.categories[any link sys.id] = MyCategoryId.
I can only find an example only where the reference field is a singleton, not an array.
Would love any help, thanks!

You could specify your query like this:
/spaces/YOURSPACEID/entries?content_type=CONTENTTYPEID&fields.categories.sys.id=SOMEID
Notice that a content type restriction is necessary as we are filtering on a field property.
Also note that this only works because we're filtering on a system property directly accessible from the actual entry returned. If you wanted to filter on another property of the Category content type, for example title or description that is not currently supported.
Here's also a link to the official documentation including examples and explanations for the search api: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/query-entries

Related

CQ5 QueryBuilder if Property has a value or has no value

I am running a query like to do determine if the page has the given tag(s)
predicates.put("property","jcr:content/cq:tags");
predicates.put("property.and","true");
predicates.put("property.1_value","properties:style");
predicates.put("property.2_value","properties:style/color");
I also want to be able to get all results that have any tag or query on all results that have no tag.
What would I put in the value section to check for these constraints
You need to set the operation parameter of the property predicate. Its semantic is described here: JcrPropertyPredicateEvaluator

Alfresco Lucene search syntax

I am writing a webscript, wherein I have a custom content model.
I want to list all the documents, that have a particular property as one of it's attributes.
Firstly I did
search.luceneSearch("PATH:\"/app:company_home//*\" AND #cm:name:myDocument")
This returned me value 1. But this query actually returns me the documents, whose cm:name property is myDocument.
what if I want to search for documents, who has cm:name property as an attribute.
So that later, I can change cm:name with mycontentmodel:myproperty, and find the elements that belong to my content type.
If I understand correctly, you'd like to find all the documents that have property mycontentmodel:myproperty, but you're not interested in the actual value of the property.
If so, find out what type or aspect mycontentmodel:myproperty belongs to.
If it belongs to type mycontentmodel:mytype the query can be:
PATH:"/app:company_home//*" AND TYPE:"mycontentmodel:mytype"
and if it belongs to aspect mycontentmodel:myaspect
PATH:"/app:company_home//*" AND ASPECT:"mycontentmodel:myaspect"

Sitecore 7, Content Search, "Content" property of the document is not showing actual content

I have managed to get search results using LINQ way, I can access different fields of the searched document, including Title, Url, Path, etc.
I can also access Content property of the document but that is not showing actual content of the document. It is showing Title of the document separated by -, for example if the searched document Title is Video news items, Content property contains Video-news-items|Video news items.
How can I get actual content of the searched document?
Code I am using to search document is explained in another post.
Based on your other question, I assume you are using the base SearchResultItem class. You can inherit from this class and add Properties that map to specific fields in your items. you can then just use the properties as normal. This article explains the process:
Sitecore 7 POCO's explained
If you haven't yet done any research into Sitecore 7 search yet, I would suggest that you do some. The concepts may not be familiar.
I think this is showing meta title for this page

Difference between FieldLinks and Field in Sharepoint

I'm in the middle of trying to copy a custom content type from one web to another. I've googled around and found some examples that use FieldLinks and Fields. I'm kind of lost as to which one to use, since when I get the FieldLinks from my source web, I get 3 fields; while retrieving from Fields only returned me 2 fields... the custom field is missing. I'm pretty darn sure that I've added the fields at the proper level since I did it via the interface. But when retrieving it using code... the numbers just don't add up.
So besides from that strange problem, I want to know what is the difference between FieldLinks and Fields, and when dealing with them in Content Types (programmatically) which one should I use?
Thanks.
SPFields are fields themselves, while SPFieldLinks are references to the fields. This is a good read that will explain things in detail. In general practice, it is safer to use SPFieldLinks when you are working on the actual content type definition. However, I'll give a quick summary here.
Lists and Webs contain the actual fields with field data. A content type, on the other hand, only holds Field Reference, which simply points at the corresponding field in the list or web. This gets a bit confusing, because content types have both an SPFieldLinkCollection and an SPFieldCollection.
The SPFieldLinkCollection is used in the actual definition of the content type, and is what you would want to use in your situation of copying a content type from one web to another. SPFieldLinks correspond to the actual elements in the XML Schema for a content type.
Comparatively, when you call on a content type's SPFieldCollection and retrieve a Field from it, what is actually happening is that the content type is checking the corresponding field reference, and then looking up in the list/web to get the actual field. Basically, think of the SPFieldCollection in the same way a lookup works: it is worthless without both the lookup value and the lookup source.

How to create a lookup column that targets a Doc Lib and uses the 'Name' of the document?

How do you create a lookup column to a Document Library that uses the 'Name' of the document as the lookup value?
I found a blog post that recommends adding another custom field like "FileName" and then using a item reciever to populate the custom field with the value from the Name field but that seems cheesy.
Link to the blog in case people are interested:
http://blogs.msdn.com/pranab/archive/2008/01/08/sharepoint-2007-moss-wss-issue-with-lookup-column-to-doc-lib-name-field.aspx
I've got a bunch of custom document content types that I dont want to clutter with a work around that should really work anyway.
I created a one step workflow to set the title from the name, fired on modify and created. Seems to work and took seconds to create.
One way you can do this (although not the easiest way) is by creating a custom field type that extends the SPFieldLookup class. SharePoint's field editor for Lookup fields purposefully hides any columns types that aren't supported by Lookup fields, but you can create a field editor for your custom field type that shows them.
However, I have created a Lookup column that points to a Name column in a Document Library before, and it probably doesn't work like you'd expect. While the value stored in the lookup column is valid, it doesn't show up right in List view or on the View Properties form.
The solution you posted may actually be the best way to handle this. Lookup fields require some kludges if you want to handle more complex scenarios, but that's because they're not meant to provide the same functionality as a foreign key relationship in a database.
Coding in any form always scares me. So Here's what I did: I simply renamed the Stupid "Title" Field to something else, say "Keywords", since you cant do anything with that field: cant even make it mandatory.
Then I created another Single line field called "Title" and used this field for the Lookups
Well there is a simple solution to that and in might work in some case.
In the nutshell if you make the Title field Mandatory, this will force the user to enter a title. In that manner we can use title field as a lookup field.
Now How to do that?
One you are done create a document library go to the library setting. Select Advance Setting and Select Yes for the option "Allow management of content types?".
Then go back to the Library setting and Under content types select the "Document" Content type. THen Select Title Column and then Select "Required (Must contain information)" and say OK.
Now try uploading a document to this document library. You will see Title field in the form.
Hope this helps
Cheers
Vaqar
You have to add the field as XML with the ShowField as 'FileLeafRef'
var XmlFieldDefinition = "<Field DisplayName='myLookupColumn' Type='LookupMulti' StaticName='myLookupColumn' Name='myLookupColumn' Required='FALSE' List='THE LOOKUP ID HERE' WebId='THE WEB ID HERE' UnlimitedLengthInDocumentLibrary='TRUE' Mult='TRUE' Sortable='FALSE' ShowField='FileLeafRef' />"
Field fld = fieldCollection.AddFieldAsXml(XmlFieldDefinition, true, AddFieldOptions.DefaultValue);
ClientContext.Load(fld);
ClientContext.ExecuteQuery();

Resources