简体   繁体   English

alfresco buildonly indexer,用于搜索动态创建的属性

[英]alfresco buildonly indexer for searching the properties created on the fly

I am using the latest version of alfresco 5.1 version. 我使用的是alfresco 5.1版本的最新版本。 one of my requirement is to create properties (key / value) where user enter the key as well as the value. 我的一个要求是创建属性(键/值),用户输入键和值。

so I have done that like this 所以我这样做了

    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(QName.createQName("customProp1"), "prop1");
    props.put(QName.createQName("customProp2"), "prop2");
    ChildAssociationRef associationRef = nodeService.createNode(nodeService.getRootNode(storeRef), ContentModel.ASSOC_CHILDREN, QName.createQName(GUID.generate()), ContentModel.TYPE_CMOBJECT, props);

Now what I want to do is search the nodes with these newly created properties. 现在我想要做的是用这些新创建的属性搜索节点。 I was able to search the newly created property like this. 我能够像这样搜索新创建的属性。

public List<NodeRef> findNodes() throws Exception {
    authenticate("admin", "admin");
    StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
    List<NodeRef> nodeList = null;
    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(QName.createQName("customProp1"), "prop1");
    props.put(QName.createQName("customProp2"), "prop2");
    ChildAssociationRef associationRef = nodeService.createNode(nodeService.getRootNode(storeRef), ContentModel.ASSOC_CHILDREN, QName.createQName(GUID.generate()), ContentModel.TYPE_CMOBJECT, props);
    NodeRef nodeRef = associationRef.getChildRef();
    String query = "@cm\\:customProp1:\"prop1\"";
    SearchParameters sp = new SearchParameters();
    sp.addStore(storeRef);
    sp.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp.setQuery(query);
    try {
        ResultSet results = serviceRegistry.getSearchService().query(sp);
        nodeList = new ArrayList<NodeRef>();
        for (ResultSetRow row : results) {
            nodeList.add(row.getNodeRef());
            System.out.println(row.getNodeRef());
        }
        System.out.println(nodeList.size());
    } catch (Exception e) {
        e.printStackTrace();
    }
    return nodeList;
}

The alfresco-global.properties indexer configuration is alfresco-global.properties索引器配置是

index.subsystem.name=buildonly
index.recovery.mode=AUTO
dir.keystore=${dir.root}/keystore

Now my question is 现在我的问题是

Is it possible to achieve the same using the solr4 indexer ? 是否有可能使用solr4索引器实现相同的目标? Or Is there any way to use buildonly indexer for a particular query ? 或者有没有办法为特定查询使用buildonly索引器?

In your query String query = "@cm\\\\:customProp1:\\"prop1\\""; 在您的查询中String query = "@cm\\\\:customProp1:\\"prop1\\""; remove cm as you are building the QName on the fly so it does not come under cm ie (ContentModel) properties. 当您在运行中构建QName时删除cm ,因此它不属于cm ie(ContentModel)属性。 So your query will be 所以你的查询将是

String query = "@\\:customProp1:\"prop1\"";

Hope this will work for you 希望这对你有用

First, double check if you're simply experiencing eventual consistency , as described below. 首先,仔细检查您是否只是遇到最终的一致性 ,如下所述。 If you are, and if this presents a problem for you, consider switching to CMIS queries while staying on SOLR. 如果您是,并且如果这给您带来了问题,请考虑在停留SOLR时切换到CMIS查询。

http://docs.alfresco.com/5.1/concepts/solr-event-consistency.html http://docs.alfresco.com/5.1/concepts/solr-event-consistency.html

Other than this, check if the node has been indexed at all. 除此之外,检查节点是否已被索引。 If it has, take a closer look at how you build your query. 如果有,请仔细查看如何构建查询。

How to find List of unindexed file in alfresco 如何在露天找到未索引文件的列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM