Is it possible to add a CQL field from OS_PROPERTYENTRY?
Sub-Question: https://answers.atlassian.com/questions/56039602
Community moderators have prevented the ability to post new answers.
Argh damn... just a little mistake in my LanguageFieldHandler
@Override public V2SearchQueryWrapper build(TextExpressionData expressionData, String value) { validateSupportedOp(expressionData.getOperator(), newHashSet(CONTAINS, NOT_CONTAINS)); return wrapV2Search(new TextFieldQuery(LanguagePropertyExtractor.INDEXABLE_PROPERTY, value, BooleanOperator.AND), expressionData); }
@Override public V2SearchQueryWrapper build(TextExpressionData expressionData, String value) { validateSupportedOp(expressionData.getOperator(), newHashSet(CONTAINS, NOT_CONTAINS)); return wrapV2Search(new TextFieldQuery(FIELD_NAME, value, BooleanOperator.AND), expressionData); }
I think i almost made it. But something is still missing/wrong with my code. Maybe someone can help me.
<cql-query-field fieldName="titleEn" key="title-en-field" name="Scroll Language EN Title" class="com.confluence.cql.LanguageFieldHandler"> <ui-support value-type="string" default-operator="~" i18n-key="cql.field.titleEn"/> </cql-query-field>
@Scanned public class LanguagePropertyExtractor implements Extractor { public static final String INDEXABLE_PROPERTY = "com.k15t.scroll.versions.translations.title.en"; private ContentPropertyManager contentPropertyManager; @Inject public LanguagePropertyExtractor(@ComponentImport ContentPropertyManager contentPropertyManager) { this.contentPropertyManager = contentPropertyManager; } public void addFields(Document document, StringBuffer defaultSearchableText, Searchable searchable) { if (searchable instanceof ContentEntityObject) { ContentEntityObject contentEntityObject = (ContentEntityObject) searchable; String value = contentPropertyManager.getTextProperty(contentEntityObject, INDEXABLE_PROPERTY); if(isNotNullOrEmpty(value)) { if (TextUtils.stringSet(value)) { defaultSearchableText.append(value).append(" "); document.add(new TextField("titleEn", value, Field.Store.YES)); } } } } }
public class LanguageFieldHandler extends BaseFieldHandler implements TextFieldHandler<V2SearchQueryWrapper>, EqualityFieldHandler<String, V2SearchQueryWrapper> { private static final String FIELD_NAME = "titleEn"; public LanguageFieldHandler() { super(FIELD_NAME, true); } @Override public V2SearchQueryWrapper build(TextExpressionData expressionData, String value) { validateSupportedOp(expressionData.getOperator(), newHashSet(CONTAINS, NOT_CONTAINS)); return wrapV2Search(new TextFieldQuery(LanguagePropertyExtractor.INDEXABLE_PROPERTY, value, BooleanOperator.AND), expressionData); } @Override public FieldOrder buildOrder(OrderDirection direction) { return new V2SearchSortWrapper(new TitleSort(V2SearchSortWrapper.convertOrder(direction))); } @Override public V2SearchQueryWrapper build(SetExpressionData expressionData, Iterable<String> values) { validateSupportedOp(expressionData.getOperator(), newHashSet(IN, NOT_IN)); SearchQuery query = joinSingleValueQueries(values, new Function<String, TextFieldQuery>() { @Override public TextFieldQuery apply(@Nullable String value) { return createEqualityQuery(value); } }); return wrapV2Search(query, expressionData); } @Override public V2SearchQueryWrapper build(EqualityExpressionData expressionData, String value) { validateSupportedOp(expressionData.getOperator(), newHashSet(EQUALS, NOT_EQUALS)); return wrapV2Search(createEqualityQuery(value), expressionData); } private TextFieldQuery createEqualityQuery(String value) { return new TextFieldQuery(LanguagePropertyExtractor.INDEXABLE_PROPERTY, "\"" + value + "\"", BooleanOperator.AND); } }
luke-translations.png
But if i use the Confluence search, i do not get any results:
{"results":[],"start":0,"limit":10,"size":0,"totalSize":0,"cqlQuery":"titleEn ~ \"Product\"","searchDuration":32,"archivedResultCount":0,"_links":{"base":"http://10.100.152.246:8090","context":""}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OS_Propertyentry does not contain field data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.