• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

categoryTree always empty

Community Beginner ,
Jan 21, 2015 Jan 21, 2015

Copy link to clipboard

Copied

I have posted this issue in the Solr sub-community, but I also noticed that there is basically zero activity there (first post in 8 months, no answers to other posts), so I am re-posting my issue in the main CF forum.

I am having difficulty getting categoryTree to populate with cfindex. I have created the collection with categories enabled, and the category column does indeed get populated. But try as I might, I cannot get the categoryTree column to populate. My indexing code is as follows:

cfindex(
     type="custom",
     autoCommit=true,
     collection=arguments.collectionName,
     action="Update",
     key=arguments.key,
     title=arguments.title,
     body=arguments.body,
     custom1=arguments.custom1,
     custom2=arguments.custom2,
     custom3=arguments.custom3,
     custom4=DateConvert( 'Local2UTC', now() ),
     category=arguments.categories,
     categoryTree=arguments.categoryTree,
     status="statusStruct");

The results of cfsearch do contain values in the category column, and listing the categories using new collection().categorylist(); shows the categories, but again no categoryTrees. I have deleted the collection and recreated it several times, including stopping the ColdFusion Add-On service, rebooting the computer (local dev, so I won't call it a server), and deleting the collection files. I have also created new collections with different names and paths, but I still have this issue every time I index any collection.

There seems to be very few people who have had such an issue since I have found very little online concerning the problem (namely, people saying it worked after they deleted and recreated the collection, and a bug submitted to Adobe - which was subsequently closed when Adobe couldn't replicate the issue). Does anyone have any ideas of what I can try?

For reference, this is CF 11 developer edition on Windows 7 using IIS for my server.

Views

414

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Feb 12, 2015 Feb 12, 2015

After an exchange with the ever knowledgeable Ray Camden, I have pinpointed the issue.

Ray sent me the following code to test:

q = queryNew("id,title,body,cat,leaf", "integer,varchar,varchar,varchar,varchar");
q.addRow({id:1,title:"Title1", body:"I like cats", cat:"sports", leaf:"football"});
q.addRow({id:2,title:"Title2", body:"I like dogs", cat:"sports", leaf:"tennis"});
q.addRow({id:3,title:"Title3", body:"I like tech", cat:"news", leaf:"tech"});

writedump(q);

cfindex(
     type="custom",
   
...

Votes

Translate

Translate
Community Beginner ,
Feb 12, 2015 Feb 12, 2015

Copy link to clipboard

Copied

After an exchange with the ever knowledgeable Ray Camden, I have pinpointed the issue.

Ray sent me the following code to test:

q = queryNew("id,title,body,cat,leaf", "integer,varchar,varchar,varchar,varchar");
q.addRow({id:1,title:"Title1", body:"I like cats", cat:"sports", leaf:"football"});
q.addRow({id:2,title:"Title2", body:"I like dogs", cat:"sports", leaf:"tennis"});
q.addRow({id:3,title:"Title3", body:"I like tech", cat:"news", leaf:"tech"});

writedump(q);

cfindex(
     type="custom",
     autoCommit=true,
     collection="test1",
     action="update",
     key="id",
     title="title",
     body="body",
     category="leaf",
     categoryTree="cat",
     query="q",
     status="statusStruct");

writedump(statusStruct);

cfsearch(collection="test1", criteria="cats", categorytree="sports", name="r");

writedump(r);

This code does indeed produce categoryTree results. So, why does this code work and my code doesn't?

If you look carefully there is one thing I don't do that ray does. While I use cfindex > type="custom" without a query parameter, Ray puts his data into a query before calling cfindex > type="custom" with a query parameter.

I have been using type="custom" without a query for a while and never had a problem... but I also wasn't using categoryTree. So it seems while using cfindex > type="custom" without a query works for most things, it doesn't support categoryTree. I don't know if this is a bug, or a reflection of the fact that perhaps we shouldn't be using type="custom" without a query.

An additional note I have is that there was a bug submitted to Adobe last year that raised this exact issue (https://bugbase.adobe.com/index.cfm?event=bug&id=3785874). Now that I know what the problem is, I find it frustrating that the Adobe tech who responded to that ticket obviously didn't test the code that was submitted. If they had, they would have been able to replicate the issue.

I don't know if using categoryTree with type="custom", but without a query, worked prior to CF 10. But it definitely doesn't work from 10 forward. Some clarification from Adobe as to whether this is a bug, or improper use by the developer, would be appreciated.

Hopefully someone out there will find this helpful some day.

John

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 14, 2015 Feb 14, 2015

Copy link to clipboard

Copied

John,

Your code doesn't make clear the kind of data you are are indexing. Your comments make it abundantly clear that you are not indexing a query, but doesn't go on to say what form your data is in. Is it a directory, a file or something else.

Specifically, what are you passing in the "key" attribute?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 19, 2015 Feb 19, 2015

Copy link to clipboard

Copied

Piyush,

Here is an example of code that does not correctly save categoryTree information.

cfindex(
    type="custom",
    autoCommit=true,
    collection="myCollection",
    action="Update",
    key="1",
    title="title",
    body="body",
    custom1="custom1",
    custom2="custom2",
    custom3="custom3",
    custom4="custom4",
    category="category",
    categoryTree="categoryTree",
    status="helper");

This index does not contain any variables. The content is not wholly from any one specific table, but it is content out of a database. What the value of the key is should not matter. The key can be used as the programmer desires upon searching the collection.

Regardless, the index action above should successfully create a record with categoryTree information (in the above case, the value of "categoryTree" should be in the categoryTree field of the result). If you create a collection and index only one record with the above code, you will find that the record's search result has a blank categoryTree column, and using collection().categorylist() shows that there are no categoryTrees in the collection.

John

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 20, 2015 Feb 20, 2015

Copy link to clipboard

Copied

LATEST

John,

The significance of the "key" attribute lies in the fact that the issue manifests only when plain text (type="custom", key="some-custom-key", body="plain text to be indexed") is passed to the cfindex tag for indexing.

It is not observed if a file or directory (type="path/file", key="#file/dir path#") or a query (type="custom", key="query", body="#query_columns#") are indexed.

Anyway, thanks for coming out with this.

The related bug, you referred to in one of your comments before, has been taken up for fixing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation