Indexation problem
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2007 01:16 PM
Hi there,
I'm adding a content through code to the repository, and then I try to search it using lucene but I have no results. Using "nint" as search string I can see that is was not indexed.
My code:
Query:
Then I'm getting the ResultSet using:
serviceRegistry.getSearchService().query(sp);
I'm using the latest Alfresco version (yesterday checkout from HEAD)
Why my new content is not being indexed?
I'm adding a content through code to the repository, and then I try to search it using lucene but I have no results. Using "nint" as search string I can see that is was not indexed.
My code:
Node node2 = this.session.getRootNode();Node child = node2.addNode("testeindex5", "cm:content");child.setProperty("cm:title", "My test");child.setProperty("cm:content", "Just a test content.");
Query:
String query = "PATH:\"//*\" AND TEXT:\"Just\" ";StoreRef sr = new StoreRef("workspace", "SpacesStore");SearchParameters sp = new SearchParameters();sp.addStore(sr);sp.setLanguage(SearchService.LANGUAGE_LUCENE);sp.setQuery(query);
Then I'm getting the ResultSet using:
serviceRegistry.getSearchService().query(sp);
I'm using the latest Alfresco version (yesterday checkout from HEAD)
Why my new content is not being indexed?
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2007 02:19 PM
Another test was made using a code similar to the way Alfresco webclient creates content and it didn't work as well 

public void saveContent(String strContent) throws Exception { // get the node ref of the node that will contain the content NodeRef containerNodeRef = JCRNodeRef .getNodeRef(getNode("/")); FileInfo fileInfo = this.serviceRegistry.getFileFolderService().create( containerNodeRef, "myTesteFileContent", QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "content")); NodeRef fileNodeRef = fileInfo.getNodeRef(); // set the author aspect Map<QName, Serializable> authorProps = new HashMap<QName, Serializable>( 1, 1.0f); authorProps.put(ContentModel.PROP_AUTHOR, "fabio"); this.serviceRegistry.getNodeService().addAspect(fileNodeRef, ContentModel.ASPECT_AUTHOR, authorProps); // apply the titled aspect - title and description Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>( 3, 1.0f); titledProps.put(ContentModel.PROP_TITLE, "teste title"); titledProps.put(ContentModel.PROP_DESCRIPTION, "teste desc"); this.serviceRegistry.getNodeService().addAspect(fileNodeRef, ContentModel.ASPECT_TITLED, titledProps); // get a writer for the content and put the file ContentWriter writer = this.serviceRegistry.getContentService() .getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true); // set the mimetype and encoding writer.setMimetype("plain/text"); writer.setEncoding("UTF-8"); writer.putContent(strContent == null ? "" : strContent); }
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2007 03:55 PM
Ha, using alfresco web code it works. The problem of the above code was the mime type.
Should be writer.setMimetype("text/plain"); not plain/text.
But using only JCR API it does not work still
Should be writer.setMimetype("text/plain"); not plain/text.
But using only JCR API it does not work still

