Comments (8)
I've never tried that before but the problems will be:
- Deleting a document is by __NodeId so it will delete them all
- Querying on __NodeId I suspect is expecting a single result but you will get more than one, not sure what will happen
It kind of goes against the contract of what Examine expects so I'm not really sure the consequences.
from examine.
Everything is based on valueSet.Id to add or update the document behind the scenes. What is the Id you are passing here? And if it is the same Id, and a new document is being added that would seem pretty strange. There's tests in the codebase here to testing updating docs which work, so does seem odd.
from examine.
Hmm on further testing it seems to be unrelated to v4. I get the same problem with v3.1.0.
I will try to reproduce on a fresh site and link the repo.
from examine.
I've set up a repo where I can reproduce the issue running Examine 3.1.0: https://github.com/jemayn/examine-duplicates
Steps:
- Build the product index, should have 4 documents:
- Add a "new" product with a matching id to one of the existing ones but a new name by calling the test api controller at https://localhost:44358/umbraco/api/test/updatevalues
- Check the index, it now has 5 documents - two of them with id 1:
from examine.
Are you using "__NodeId" as the key?
from examine.
I am calling it like this:
private readonly IExamineManager _examineManager;
private readonly ProductIndexValueSetBuilder _productIndexValueSetBuilder;
public TestController(IExamineManager examineManager, ProductIndexValueSetBuilder productIndexValueSetBuilder)
{
_examineManager = examineManager;
_productIndexValueSetBuilder = productIndexValueSetBuilder;
}
public void UpdateValues()
{
if (!_examineManager.TryGetIndex(IndexingConstants.IndexName, out var index))
{
return;
}
var product = new Product
{
Id = 1,
Name = "Name with update 1"
};
index.IndexItems(_productIndexValueSetBuilder.GetValueSets(product));
}
And the valueset builder looks like this:
public class ProductIndexValueSetBuilder : IValueSetBuilder<Product>
{
public IEnumerable<ValueSet> GetValueSets(params Product[] products)
{
foreach (var product in products)
{
var indexValues = new Dictionary<string, object>
{
[UmbracoExamineFieldNames.NodeNameFieldName] = product.Name,
["id"] = product.Id
};
yield return new ValueSet(
product.Id.ToString(),
IndexingConstants.IndexType,
IndexingConstants.IndexType,
indexValues);
}
}
}
So I am setting the string Id param in the ValueSet constructor to product.Id.ToString() which seems to set it in the __NodeId field. I also tried adding it as a specific field, but then it gets added twice like this:
from examine.
I think its because you are overriding the field type of the key __NodeId here
from examine.
Ohhh hadn't considered that not all fields need to be explicitly set.
I tried removing that line and now it works as expected! Thanks!
On a similar note, is it problematic in any way to have multiple index documents with the same id?
Say fx you had products and they had multiple language versions, would there be any benefits to doing it like this:
__NodeId: 1
nodeName: Product 1
description_da-dk: Description in Danish
description_en-gb: Description in English
Versus this:
__NodeId: 1
nodeName: Product 1
culture: da-dk
description: Description in Danish__NodeId: 1
nodeName: Product 1
culture: en-gb
description: Description in English
from examine.
Related Issues (20)
- And( q=> q.GroupedOr(...)) adds and (+) to the first term of the groupedOr HOT 3
- Abstaction of LuceneIndex.cs HOT 5
- Any plan to release new Version HOT 2
- Sorting and paging highlight same both menu items HOT 6
- Content without an English (default language) version is not indexed HOT 1
- Synchronous indexing HOT 8
- Failed to retrieve indexer details. HOT 3
- Query by Id does not return search result HOT 5
- ❓ How to tell if an Examine Index is Healthy? Possible ASPNET HealthCheck 💡 HOT 2
- NativeQuery performance CPU usage HOT 5
- Same query but different results if executed as NativeQuery vs Fluent API HOT 7
- Hardcoded default limit of max 500 search results is not obvious
- GetMultiFieldQuery shouldn't return an empty lucene query if there are no field values
- Examine on load balanced environment HOT 8
- Getting Searcher Synchronously? HOT 4
- Lucene.Net.Index.CorruptIndexException: invalid deletion count: 2 vs docCount=1 HOT 7
- Wildcard search in `GroupedOr()` HOT 13
- How to make a boosted phrase with FluentAPI? HOT 2
- Field $facets was not indexed with SortedSetDocValues
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from examine.